Ensure underscore build internal forOwn will accept a thisArg argument. [closes #220].

Former-commit-id: a7818db29e81b64556232bfe44b2e1275d3dada1
This commit is contained in:
John-David Dalton
2013-03-26 20:46:02 -07:00
parent 2c7cc2c191
commit d77c9d3fca
6 changed files with 22 additions and 12 deletions

View File

@@ -899,6 +899,18 @@
equal(last, _.last(array), '_.forEach should not exit early: ' + basename);
equal(actual, undefined, '_.forEach should return `undefined`: ' + basename);
lodash.forEach([1], function(value, index) {
actual = this[index];
}, [2]);
equal(actual, 2, '_.forEach supports the `thisArg` argument when iterating arrays: ' + basename);
lodash.forEach({ 'a': 1 }, function(value, key) {
actual = this[key];
}, { 'a': 2 });
equal(actual, 2, '_.forEach supports the `thisArg` argument when iterating objects: ' + basename);
array = [{ 'a': [1, 2] }, { 'a': [3] }];
actual = lodash.flatten(array, function(value, index) {