Skip to content

Instantly share code, notes, and snippets.

@extrabacon
Created March 5, 2014 20:33
Show Gist options
  • Save extrabacon/9375999 to your computer and use it in GitHub Desktop.
Save extrabacon/9375999 to your computer and use it in GitHub Desktop.
Flattening an array
function flattenArray(array) {
var results = [];
var self = arguments.callee;
array.forEach(function(item) {
Array.prototype.push.apply(results, Array.isArray(item) ? self(item) : [item]);
});
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment