Last active
May 2, 2017 06:44
-
-
Save avishwakarma/0148adbf184f8b8de63827ad50e682c2 to your computer and use it in GitHub Desktop.
JavaScript Array Flat / Merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* flat / merge all sub array into one array | |
* @uses [['1', '2'], ['3', '4], '5', '6'].flat(); // ['1', '2', '3', '4', '5', '6'] | |
*/ | |
Array.prototype.flat = function(){ | |
return [].concat.apply([], this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment