Skip to content

Instantly share code, notes, and snippets.

@DAB0mB
Created December 31, 2017 06:30
Show Gist options
  • Save DAB0mB/6c038caafa914998b0a1be1ae525040e to your computer and use it in GitHub Desktop.
Save DAB0mB/6c038caafa914998b0a1be1ae525040e to your computer and use it in GitHub Desktop.
A JavaScript function to flat an array recursively
function flattenDeep(array) {
if (!(array instanceof Array)) {
return array;
}
return array.reduce((flatArray, cell) => {
return flatArray.concat(flattenDeep(cell));
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment