Skip to content

Instantly share code, notes, and snippets.

@basekays
Created January 24, 2017 20:17
Show Gist options
  • Select an option

  • Save basekays/56e4ae12a9f0c0233ef12cf43ff8f43b to your computer and use it in GitHub Desktop.

Select an option

Save basekays/56e4ae12a9f0c0233ef12cf43ff8f43b to your computer and use it in GitHub Desktop.
-
_.each = function(collection, iterator) {
if (Array.isArray(collection)) {
for (var i = 0; i<collection.length; i++) {
return iterator(collection[i], i, collection);
}
} else {
for (var i in collection) {
return iterator(collection[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment