var object1 = {
a: 1,
b: 3
};
Object.assing(object1, {b: 5});
This will make:
object1 = {
a: 1,
b: 5
}
The question is can this be achieved by spread operator ... Which will return new Object instead of updating object1
var object2 = {...object1, b: 5}
Same as:
var object2 = Object.assign{{}, object1, {b: 5}}
Here
object2 = {
a: 1,
b: 5
}
but
object1 {
a: 1,
b: 3
};