Permalink
Browse files

Converting obj to Object allows string primitives to be used in _.eac…

…h and similar functions.
  • Loading branch information...
1 parent 67706cf commit 5fb5333366755751356c434f3e4a88932a75a8ac @pepkin88 committed Apr 19, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 underscore.js
View
@@ -75,8 +75,9 @@
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
+ var objectObj = new Object(obj);
for (var i = 0, l = obj.length; i < l; i++) {
- if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
+ if (i in objectObj && iterator.call(context, obj[i], i, obj) === breaker) return;
}
} else {
for (var key in obj) {

0 comments on commit 5fb5333

Please sign in to comment.