Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Turn a nested array in to a single array of components
// [[1,2,[3]],4] -> [1,2,3,4]
var unflattenedArray = [[1,2,[3]],4],
flattenedArray = [];
flattenedArray = unflattenedArray.toString().split(',').map(function(arrayItem) {
return parseInt(arrayItem);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.