Skip to content

Instantly share code, notes, and snippets.

@svahora
Created August 9, 2015 15:46
Show Gist options
  • Save svahora/46644856a56fb2c52fdb to your computer and use it in GitHub Desktop.
Save svahora/46644856a56fb2c52fdb to your computer and use it in GitHub Desktop.
function steamroller(arr) {
var flat = [],
i;
for (i = 0; i < arguments.length; i++) {
if (arguments[i] instanceof Array) {
flat = flat.concat(steamroller.apply(null, arguments[i]));
} else {
flat.push(arguments[i]);
}
}
return flat;
}
steamroller([1, [2], [3, [[4]]]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment