Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there any reason that array checking for _.each goes off of presence of .length? #724

Closed
mbriggs opened this issue Aug 28, 2012 · 2 comments

Comments

@mbriggs
Copy link

mbriggs commented Aug 28, 2012

Helped a co-worker this morning try to figure out why _.each wasn't working for his object (which happened to have a length field on it). There are several ways to check for arrays that I know of (Object.prototype.toString, checking constructor), is there any reason that the choice was made to go for .length?

@jashkenas
Copy link
Owner

Yep -- so that we support both arrays and array-like objects: arguments, NodeLists, and so on.

@jdalton
Copy link
Contributor

jdalton commented Aug 30, 2012

@mbriggs I've addressed this with _.forIn and _.forOwn. Lemme know if that works for ya.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants