Skip to content

Instantly share code, notes, and snippets.

@filipmares
Created January 29, 2013 07:57
Show Gist options
  • Save filipmares/4662570 to your computer and use it in GitHub Desktop.
Save filipmares/4662570 to your computer and use it in GitHub Desktop.
Helper function that returns a falt array
function _loader(array){
var flat = [];
for (var i = 0, l = array.length; i < l; i++){
var type = Object.prototype.toString.call(array[i]).split(' ').pop().split(']').shift().toLowerCase();
if (type) { flat = flat.concat(/^(array|collection|arguments|object)$/.test(type) ? _flat(array[i]) : array[i]); }
}
return flat;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment