Nodejs Array Concatenate concatAll()

Here you can find the source of concatAll()

Method Source Code

Array.prototype.concatAll = function() {
    let result = [];//from  w w w .  ja v a2  s . c  om

    this.forEach(items => 
        result = result.concat(items)
    );

    return result;
}

Related

  1. concat(arg)
    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];
        console.log(result);
    var piyo=new Array(100,200,300);
    ...
    
  2. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        results.push.apply(results, subArray);
      });
      return results;
    };
    
  3. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(item) {
          results.concat(item);
        });
      });
      return results;
    
  4. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(innerData){return results.push(innerData)})
      });
      return results;
    };
    
  5. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(element) {
          results.push(element);
        });
      });
      return results;
    };
    ...
    
  6. concatAll()
    Array.prototype.concatAll = function() {
      let results = [];
        for (let i = 0; i < this.length; i++) {
            results.push.apply(results, this[i]);
      return results;
    };
    
  7. concatAll()
    Array.prototype.concatAll = function() {
      return this.reduce((results, current) => {
        if(Array.isArray(current)) {
            return results.concat(current).concatAll();
        } else {
            return (results.push(current), results);
      }, []);
    };
    ...
    
  8. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        if (Array.isArray(subArray)) {
          subArray.forEach(function(item) {
            results.push(item);
          });
      });
    ...
    
  9. concatAll()
    Array.prototype.concatAll = function () {
      let results = [];
      this.forEach(function (subArray) {
        results.push.apply(results, subArray);
      });
      return results;
    };