Here you can find the source of mergeAll()
Array.prototype.mergeAll = function() { var results = []; this.forEach(function(subArray) { subArray.forEach(function(number) { results.push(number);//from w w w . ja va2 s . c o m }); }); return results; }; var result = JSON.stringify([ [1,2,3], [4,5,6], [7,8,9] ].mergeAll()); console.log(result); console.log(result === "[1,2,3,4,5,6,7,8,9]"); // [1,2,3].mergeAll(); // throws an error because this is a one-dimensional array
var school = [ [1, 2, 3], [4, 5, 6, 7, 8, 3], [5, 3, 5] ]; Array.prototype.mergeAll = function() { var result = []; this.forEach(function(subArray) { result.push.apply(result, subArray); ...
Array.prototype.mergeAll = function() { var results = []; this.forEach(function(subArray) { subArray.forEach(function(element) { results.push(element); }); }); return results; }; ...
Array.prototype.mergeAll = function() { var results = []; this.forEach(function(subArray) { subArray.forEach(function(itemInArray) { results.push(itemInArray); }); }); return results; }; ...
Array.prototype.mergeAll = function(){ var result = []; this.forEach(function(subArray){ subArray.forEach(function(item){ result.push(item); }) }) return result;
Array.prototype.mergeAll = function(){ var result = []; this.forEach(function(subArray){ subArray.forEach(function(item){ result.push(item); }) }) return result; var a = [[1,2],[3,4]]; a.mergeAll();