Skip to content

Instantly share code, notes, and snippets.

@lai32290
Created May 19, 2016 02:40
Show Gist options
  • Save lai32290/1bd86aeada7326c6d147df89b84a206d to your computer and use it in GitHub Desktop.
Save lai32290/1bd86aeada7326c6d147df89b84a206d to your computer and use it in GitHub Desktop.
Array Flat Function
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