Skip to content

Instantly share code, notes, and snippets.

@manojktechie
Created September 14, 2016 16:19
Show Gist options
  • Save manojktechie/8b80a5092ddbd6f0f42001942917de64 to your computer and use it in GitHub Desktop.
Save manojktechie/8b80a5092ddbd6f0f42001942917de64 to your computer and use it in GitHub Desktop.
function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment