Implode array - Node.js Array

Node.js examples for Array:Array Operation

Description

Implode array

Demo Code

  Array.prototype.implode = function (s) {
  
    var string = '';
  
    for (var i = 0; i < this.length; i ++) {
      //from   w w w  . j  a v a 2 s .  c  o m
      string += this[i] + s;
      
    }
    
    var regexp = new RegExp(s + '$', 'ig');
    
    return string.replace(regexp, '');
  
  }

Related Tutorials