In javascript, I would like to combine two objects into one. I got
{ test: false, test2: false }
and
{ test2: true }
I tried using $.extend , $.merge , but all I get as a result is
{ test2: true }
How to get this conclusion
{ test: false, test2: true }
EDIT: Actually, I have nested objects. I need to combine a and b as follows:
var a = { test: false, test2: { test3: false, test4: false } }; var b = { test2: { test4: true } }; // desired combined result: { test: false, test2: { test3: false, test4: true } }
but the actual result I get removes test3 from the test2 nested object.
source share