JavaScript | JavaScript Objects | Question 7

Last Updated :
Discuss
Comments

What will the following code log?

JavaScript
const obj = { a: 1 };
obj.b = 2;
console.log(obj);


{ a: 1 }

{ a: 1, b: 2 }

Error

undefined

Share your thoughts in the comments