Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make _.each skip holes in sparse arrays.
Most immediately, this change is required to match the behavior of the native forEach method. The changes to _.isEmpty are required to fulfill the promises of this comment: "An 'empty' object has no enumerable own-properties." In general, wherever we bother to skip non-own object properties using _.has, we should be careful to skip array holes as well.
- Loading branch information
6afc156
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were two reasons to use
i in obj
instead of_.has(obj, i)
:in
keyword is much faster: http://jsperf.com/has-vs-inArray.prototype
, which would be completely insane!