-
-
Notifications
You must be signed in to change notification settings - Fork 37
Overwriting array properties. #13
Comments
@bobrenjc93 In my opinion that is the expected behavior, because we Recursively Object.assign(): deep_assign({a: [1]}, {a: []})
// should be similar to
{a: deep_assign([1], [])}
// which have to be the same as
{a: Object.assign([1], [])} (If This is consistent to the current |
I completely understand the recursive nature of this function. The question is what should be the base case. In my opinion, I think it only makes to recurse further if the value is a true object and not an array. In the event the value is not an object, the recursion should halt and behave the same way you'd expect a non recursive Object.assign for that particular value. Perhaps it would be good to have the context under which this module was developed. I'm currently trying to use this module for a redux application and the behavior I described above was what I would expect in a recursive Object.assign module. |
True Object is the crux of the matter: e.g Javascript also considers functions to be objects, and there seems no generally accepted definition for True Objects. npm and bower contain myriad packages for merging/extending/… objects – most of them without a precise semantic. If you agree with me that Plain Objects are the one and only True Objects, schnittstabil/merge-options may meet your requirements. As |
Ah okay makes sense. merge-options is exactly what I need, I'll go use that. Thanks! |
Is this intended behavior?
Based on the behavior of
Object.assign
(this module is just a recursive version of it correct?), I would have assumed it should have returnedObject {a: Array[0]}
The text was updated successfully, but these errors were encountered: