Skip to content

Instantly share code, notes, and snippets.

@JaeYeopHan
Created February 24, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaeYeopHan/54d1c4fb55f2a94c90012c18d56d88d0 to your computer and use it in GitHub Desktop.
Save JaeYeopHan/54d1c4fb55f2a94c90012c18d56d88d0 to your computer and use it in GitHub Desktop.
JavaScript function utils - Deep Flatten
function flatten(arr) {
return function f(arr, newArr) {
arr.forEach(function(v)) {
Array.isArray(v) ? f(v, newArr) : newArr.push(v);
});
return newArr;
}(arr, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment