Don't mutate array during #remove. [closes #1079]

This commit is contained in:
Justin Ridgewell
2015-03-26 11:08:13 -04:00
committed by jdalton
parent b1a81a85b1
commit d2b98323dd
2 changed files with 25 additions and 3 deletions

View File

@@ -12417,6 +12417,13 @@
_.remove(array, function(num) { return num == null; });
deepEqual(array, [1, 3]);
});
test('should not mutate the array until all elements to remove are determined', 1, function() {
var array = [1, 2, 3];
_.remove(array, function(num, i) { return i % 2 == 0; });
deepEqual(array, [2]);
});
}());
/*--------------------------------------------------------------------------*/