I have and object1 with a unknown key name and i need to merge with other object2. The secure point is that unknown key is not present in the object2 so, never gonna be key names conflicts.
var object1 = {
id: 1,
name: "myname",
boleanSample : true
}
var object2 = {
unknownKeyName : "UnknownValue"
}
I want to merge object2 into object1 and get this
var object1 = {
id: 1,
name: "myname",
boleanSample : true,
unknownKeyName = "UnknownValue"
}
Please, vanilla Javascript only. If the response require the creation of an new object3 is totally fine :)
PD: I checked these links before post the question:
- Merge Javascript Objects ( uses arrays... )
- Merging Javascript Objects ( Just for known keys, not useful for this case )
- Merging Javascript Objects on Property ( Bad post, no sense )
No duplication at all for those :)