Nodejs Array Concatenate concatAll()

Here you can find the source of concatAll()

Method Source Code

Array.prototype.concatAll = function() {
   var results = [];
   this.forEach(function(subArray) {

      // Add all the items in each subArray to the results array.
    if (Array.isArray(subArray)) {
      subArray.forEach(function(item) {
         results.push(item);//from ww w.  j av a  2 s.  com
      });
    }
   });

   return results;
};

Related

  1. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(innerData){return results.push(innerData)})
      });
      return results;
    };
    
  2. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(element) {
          results.push(element);
        });
      });
      return results;
    };
    ...
    
  3. concatAll()
    Array.prototype.concatAll = function() {
        let result = [];
        this.forEach(items => 
            result = result.concat(items)
        );
        return result;
    
  4. concatAll()
    Array.prototype.concatAll = function() {
      let results = [];
        for (let i = 0; i < this.length; i++) {
            results.push.apply(results, this[i]);
      return results;
    };
    
  5. 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);
      }, []);
    };
    ...
    
  6. concatAll()
    Array.prototype.concatAll = function () {
      let results = [];
      this.forEach(function (subArray) {
        results.push.apply(results, subArray);
      });
      return results;
    };
    
  7. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach((i) => {
          results.push(i);
        });
      });
      return results;
    };
    ...
    
  8. concatAll()
    let data = [
        [
            {name: "IBM", price:12},
            {name: "Apple", price:120}        
        ],
        [
            {name: "Google", price:100},
            {name: "MorganStanley", price:30}        
        ]
    ...
    
  9. concatAll()
    Array.prototype.concatAll = function() {
      var results = [];
      this.forEach(function(subArray) {
        subArray.forEach(function(item){
          results.push(item)
        })
      });
      return results;
    };
    ...