Created
May 19, 2016 02:40
-
-
Save lai32290/1bd86aeada7326c6d147df89b84a206d to your computer and use it in GitHub Desktop.
Array Flat Function
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
var arrayFlat = function (arr) { | |
var result = []; | |
arr.forEach(function (item) { | |
if(Array.isArray(item)) { | |
result = result.concat(toArray(item)); | |
return; | |
} | |
result.push(item); | |
}); | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment