Add _.forEach thisArg unit test to test.js.

Former-commit-id: b3d16d90789e76df778ac3457f68fdcbc3f6f4ad
This commit is contained in:
John-David Dalton
2013-03-27 07:55:19 -07:00
parent d77c9d3fca
commit 639c8d4171
2 changed files with 20 additions and 11 deletions

View File

@@ -865,6 +865,20 @@
equal(wrapper.forEach(Boolean), wrapper);
});
test('supports the `thisArg` argument', function() {
var actual;
function callback(value, index) {
actual = this[index];
}
_.forEach([1], callback, [2]);
equal(actual, 2);
_.forEach({ 'a': 1 }, callback, { 'a': 2 });
equal(actual, 2);
});
_.each({
'literal': 'abc',
'object': Object('abc')