How to combine two JSON objects, but not include properties that do not exist in the first object?
Enter
var obj1 = { x:'', y:{ a:'', b:'' } };
var obj2 = { x:1, y:{ a:1, b:2, c:3 }, z:'' };
Output
obj1 = { x:1, y:{ a:1, b:2 } };
ps. There is a method for objects called preventExtensions , but it seems to block the immediate extension of properties, not the deeper ones.
vsync source
share