Skip to content

Instantly share code, notes, and snippets.

@austbot
Created June 9, 2016 18:47
Show Gist options
  • Save austbot/3ab71fec5216b342e3b157b583c338b0 to your computer and use it in GitHub Desktop.
Save austbot/3ab71fec5216b342e3b157b583c338b0 to your computer and use it in GitHub Desktop.
function flatten(arrInput) {
if(arrInput.length < 1 || !arrInput) return [];
var arr = [];
arrInput.map(function(e, index){
if(Array.isArray(e)) arr= arr.concat(flatten(e));
else arr.push(e);
});
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment