Nodejs Utililty Methods Array Flatten

List of utility methods to do Array Flatten

Description

The list of methods to do Array Flatten are organized into topic(s).

Method

flattenArray()
Array.prototype.flattenArray = function()
  var rescultArray=[];
    this.reduce(function(pre, cur,index) 
      rescultArray=index==1?rescultArray.concat(pre,cur):rescultArray.concat(cur);
     });
   return rescultArray;
var arrays = [[1, 2, 3], [4, 5], [6]];  
console.log(arrays.flattenArray());
flattenArray()
Array.prototype.flattenArray =  function (){
  var array = this.reduce(function(a, b) {return a.concat(b);}, []);
  return array;
var arrays = [[2, 3, 4], [1, 2], [2]];
console.log( arrays.flattenArray() );
flattenArray()
var arrays = [[1, 2, 3], [4, 5], [6]];
Array.prototype.flattenArray = function() 
      arrays.reduce(function(previousValue, currentValue, index, array) 
        console.log(previousValue+"---"+currentValue);
        return previousValue.concat(previousValue);
      });
console.log(arrays.flattenArray);
flattenInPlace()
Array.fill = function(count, generator){
  var a = new Array(count)
  for(var i=0; i<count; i++){
    a[i] = generator(i)
  return a
function isDefined(a){
  return (a !== null) && (a !== undefined)
...