diff --git a/test/collections.js b/test/collections.js index e1dc5ebfc..91027f217 100644 --- a/test/collections.js +++ b/test/collections.js @@ -132,12 +132,15 @@ $(document).ready(function() { }); test('collections: any', function() { + var nativeSome = Array.prototype.some; + Array.prototype.some = null; ok(!_.any([]), 'the empty set'); ok(!_.any([false, false, false]), 'all false values'); ok(_.any([false, false, true]), 'one true value'); ok(!_.any([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers'); ok(_.any([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number'); ok(_.some([false, false, true]), 'aliased as "some"'); + Array.prototype.some = nativeSome; }); test('collections: include', function() { diff --git a/underscore.js b/underscore.js index d007edf57..5c707e99f 100644 --- a/underscore.js +++ b/underscore.js @@ -186,10 +186,10 @@ if (obj == null) return result; if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); each(obj, function (value, index, list) { - if (result |= iterator.call(context, value, index, list)) return breaker; + if (result |= iterator.call(context, value, index, list)) return breaker; }); return !!result; - } + }; // Determine if a given value is included in the array or object using `===`. // Aliased as `contains`.