-
-
Notifications
You must be signed in to change notification settings - Fork 37
property with null value in source object not overwriting to same property in target object #23
Comments
Unfortunately, this's on purpose. From MDN:
More precisely, this is due to the ECMAScript® 2015 Language Specification; 19.1.2.1
As deepAssign({}, {Lat: null, …}, {Lat: null, …})
// should be similar to
{Lat: deepAssign(<?>, null, null), …}
// which have to be the same as
{Lat: Object.assign(<?>, null, null), …} The Hence, I believe
|
This is strange behavior suggested by ECMA. Null may b a valid and intended value from source. How come not accept it? Also deepAssign must provide an option to even allow such kind of merging. |
It would be nice to provide options somehow, but the signature is:
If you have an idea, which does not conflict with the semantics of Btw, we must not provide an option – we are free to do; and we are not ECMA of course 😉. @topgun743 Anyway, does neither |
Looks like I have to turn towards your suggestion. Yes, |
BTW, you can allow a last object as an option config sort of to
This way it would be assumed that even null values from source should be forced onto the target. I think it should work. |
Sadly, because of the |
Hi Dev,
Following is not working correct:
var deepAssign = require("deep-assign");
deepAssign({}, {Lat: null, Lon: null}, {Lat: null, Lon: 2})
output is:
{Lon: 2}
It must be:
{Lat: null, Lon 2}
Due to this weird issue, my form validation is failing as Lat property is totally missing from output.
If I use Object.assign, it works correctly.
Can you plz guide me what is wrong?
The text was updated successfully, but these errors were encountered: