Closed KurtPreston closed 9 years ago
Correct. Actual behavior is correct. It just replace value of key, and only if values is objects both then it extends target object.
Sorry, I realized my example was a bit confusing -- I was re-using variable names. This one is a little clearer:
object1 = {'key': [1]}
object2 = {'key': [2]}
_.deepExtend({}, object1, object2)
deepExtend will return the correct value (i.e. {key: [2]}
). However, in doing so, it will modify the value of object1
. To be consistent with underscore.js, It should only be modifying the value of the first argument.
@KurtPreston It doesn't modify value of object1
, it modify first argument object ({}
). You can see it in this unit test: https://github.com/unclechu/node-deep-extend/blob/master/test/index.spec.js#L70-L79
Expected behavior: deepExtend tries to combine the Objects, but does not modify the data in
a
,b
, orc
.Actual behavior: deepExtend modifies the value of
a
.