dont try to look at the keys of zero-length arrays or arguments objects when calling each()

This commit is contained in:
Jeremy Ashkenas
2009-12-07 23:41:55 -05:00
parent 2afcffb30a
commit 30329c051b

View File

@@ -42,7 +42,7 @@
try {
if (obj.forEach) {
obj.forEach(iterator, context);
} else if (obj.length) {
} else if (obj.length || obj.length === 0) {
for (var i=0, l=obj.length; i<l; i++) iterator.call(context, obj[i], i, obj);
} else {
var keys = _.keys(obj), l = keys.length;