Skip to content

Instantly share code, notes, and snippets.

@khawerrind
Created December 19, 2016 21:07
Show Gist options
  • Save khawerrind/b678cbc26a08940f179e498737f81b46 to your computer and use it in GitHub Desktop.
Save khawerrind/b678cbc26a08940f179e498737f81b46 to your computer and use it in GitHub Desktop.
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
//FIDDLE: https://jsfiddle.net/sujLLtua/
var array = [[1,2,[3]],4,[5,6,[7]]];
var result = array.join().split(",").map(function(x){
return parseInt(x)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment