Nodejs Array Concatenate concat(arg)

Here you can find the source of concat(arg)

Method Source Code

var my_array=Array.prototype.concat;
Array.prototype.concat=function (arg) {
    var result = arg[0];
    for (var i = 1; i < arg.length; i++) {
        result += "-" + arg[i];
    }//w  ww .  j  a v  a2 s.  c o  m
    console.log(result);
}

var piyo=new Array(100,200,300);
piyo.concat(new Array(10,20,30,40,50));
var piyo=new Array(100,200,300);
piyo.concat(new Array("foo","baz","bar"));

Related

  1. concat()
    Array.prototype.concat = function(){
      var result = [];
      this.forEach(function(subArray){
        result.push.apply(result, subArray);
      });
      return result;
    var a = [[2,3,4,5],[11,2,333],[33,232,21]];
    a.concat();
    ...
    
  2. concat(ar)
    Array.prototype.concat = function(ar) {
      var results = new Array(this.length + ar.length);
      for (var i = 0, len = this.length; i < len; i++) {
        results[i] = this[i];
      for (var i = 0, len = ar.length; i < len; i++) {
        results[len + i] = ar[i];
      return results;
    ...
    
  3. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        results.push.apply(results, subArray);
      });
      return results;
    };
    
  4. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(item) {
          results.concat(item);
        });
      });
      return results;
    
  5. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(innerData){return results.push(innerData)})
      });
      return results;
    };
    
  6. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(element) {
          results.push(element);
        });
      });
      return results;
    };
    ...