_.each fails on objects with a length property #448

Closed
code-punkt opened this Issue Jan 27, 2012 · 1 comment

Projects

None yet

1 participant

@code-punkt

because of this check

obj.length === +obj.length

objects with a length property get treated as an array.

// logs nothing
_.each({ one: 1, two: 2, length: 3 }, function(num) { console.log(num); });

is this the desired behavior? even though this should be faster than {}.toString.call(obj) === '[object Array]', this doesn't seem right.

@code-punkt code-punkt closed this Jan 27, 2012
@code-punkt

seems this has been discussed before.
sorry for the inconvenience ;)

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