Skip to content

Instantly share code, notes, and snippets.

@jonasantonelli
Last active January 16, 2019 12:32
Show Gist options
  • Save jonasantonelli/0c0ce127b7e0fc819ddb4f4eaf9c7a68 to your computer and use it in GitHub Desktop.
Save jonasantonelli/0c0ce127b7e0fc819ddb4f4eaf9c7a68 to your computer and use it in GitHub Desktop.
function flattenDeep(arr) {
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), []);
}
flattenDeep([[1,2,[3]],4]);
@jonasantonelli
Copy link
Author

Flatten Deep JS function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment