I have two JavaScript objects with the structure below.
var obj1 = {id1: 10, name1: "stack"};
var obj2 = {id2: 20, name2: "overflow"};
I want to concat them together as a single object (not array) using Javascript.
The result should be like this.
var res = {id: 10, name1: "stack", id2: 20, name2: "overflow"};
Is there an easy way to do this using pure javascript?
Note: I don't need jQuery to do this and I want to concat is for json objects, not as json arrays using concat
method. Is there any simple method or way to achieve this?