Created
January 29, 2013 07:57
-
-
Save filipmares/4662570 to your computer and use it in GitHub Desktop.
Helper function that returns a falt array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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