Javascript Array join(separator = ',')

Description

Javascript Array join(separator = ',')



Array.prototype.join = function(separator = ',') {
 let result = '';
 for (let i = 0, len = this.length; i < len; i++) {
  if (i === 0) {//from  w  ww  .j  a va  2  s .c  om
   result += this[i];
  } else {
   result += separator + this[i];
  }
 }
 return result;
}



PreviousNext

Related