Skip to content

Instantly share code, notes, and snippets.

@dhchow
Created February 21, 2011 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhchow/837602 to your computer and use it in GitHub Desktop.
Save dhchow/837602 to your computer and use it in GitHub Desktop.
JS quiz: What does this method do?
function doesSomething(array){
var result = [];
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) ? doesSomething(array[i]) : array[i]); }
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment