You would write your code like this:
var obj1 = {a: 'A', b: 'B', c: 'C'} var obj2 = {...obj1, c: 'D'} console.log(obj2)
Writing ...obj1 will fill obj2 with obj1's contents, and writing c: 'D' will overwrite c: 'c'.
Note, ordering is important, as maheer mentioned, because the object will be written in order, from each property, which can mess up ordering of keys, and setting incorrect values:
var obj = {a: 'A', b: 'B', c: 'C'} var ex1 = {...obj, c: 'D'} var ex2 = {c: 'D', ...obj} var ex3 = {c: 'D', ...obj, c: 'E'} console.log('Example 1:', ex1) console.log('Example 2:', ex2) console.log('Example 3:', ex3)