Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created February 14, 2014 06:43
Show Gist options
  • Save kanakiyajay/8996750 to your computer and use it in GitHub Desktop.
Save kanakiyajay/8996750 to your computer and use it in GitHub Desktop.
Flatten any array of any level using recursive function
var flattenRecursive = function (arr) {
return arr.reduce(function (a,b) {
if (b instanceof Array) {
return a.concat(flattenRecursive(b));
}else{
return a.concat(b);
}
},[]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment