Flatten array into string - Node.js Array

Node.js examples for Array:Associate Array

Description

Flatten array into string

Demo Code

//  wrap each element by *prefix*,*suffix* params
//  join by *infix* param
 
Array.prototype.flatten = 
function flatten(prefix,suffix,infix) 
{
  return this.wrapEach(prefix||"",suffix||"").join(infix||"");
}

Array.prototype.each =//w  w w  .j  a v  a  2  s  .c  o m
function each(f)
{
  var ret = [ ];
  for (var i = 0; i < this.length; i++)
    ret.push( f.call( this[i], i ) );
  return ret;
}

Related Tutorials