loading...

re: Simple concepts of Modern JavaScript VIEW POST

FULL DISCUSSION
 
const obj1 = {a: 'a', b: 'b'};
const obj2 = {c: 'c', ...obj1};
console.log(obj2);

//The console will log: Object {  a: "a",  b: "b",  c: "c"}


In this case the output is

// Object {c: "c", a: "a",  b: "b"}

I guess you meant to write something like

const obj2 = {...obj1, c: 'c'};

code of conduct - report abuse