Make _.defaults follow _.assign and only assign own properties of source.

Former-commit-id: 114dc47bbfa6db6a53a2fa03dd477fe86c3395cb
This commit is contained in:
John-David Dalton
2012-11-11 16:16:11 -08:00
parent 797a87ca26
commit 82e58f2bf9
4 changed files with 41 additions and 2 deletions

View File

@@ -651,6 +651,12 @@
equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename);
equal(lodash.every([true, false, true]), false, '_.every: ' + basename);
function Foo() {}
Foo.prototype = { 'a': 1 };
deepEqual(lodash.defaults({}, new Foo), Foo.prototype, '_.defaults should assign inherited `source` properties: ' + basename);
deepEqual(lodash.extend({}, new Foo), Foo.prototype, '_.extend should assign inherited `source` properties: ' + basename);
actual = lodash.find(array, function(value) {
return 'value' in value;
});