Skip to content

Instantly share code, notes, and snippets.

@vampyar
Last active March 30, 2018 17:24
Show Gist options
  • Save vampyar/8806c092cba92ef946b4bdb2340bfb2e to your computer and use it in GitHub Desktop.
Save vampyar/8806c092cba92ef946b4bdb2340bfb2e to your computer and use it in GitHub Desktop.
customFlatten
const customFlatten = (arr) => {
return arr.reduce((initFlat, toFlat) => {
return initFlat.concat(Array.isArray(toFlat) ? customFlatten(toFlat) : toFlat);
}, [])
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment