Is there anything like this in JavaScript? Basically, I'm looking for something along these lines:
let obj_a = {test: "one", property: "two"};
let obj_b = {test: "1", other: "three"};
let obj_b ...= obj_a; // would be the equivalent of obj_b = {...obj_b, ...obj_a}
Is there builtin syntax for something like that, or is this the best I'm going to get in ES6?
Object.assign would do.
let obj_a = { test: "one", property: "two" },
obj_b = { test: "1", other: "three" };
Object.assign(obj_b, obj_a);
console.log(obj_b);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With