8.
What is the final value of obj if we run the following code snippet?
const obj = { foo: 1 };
obj.foo = 2;
console.log(obj)
Error, you cannot modify a constant object.
{ foo: 1 }
{ foo: 2 }
{ foo: 1, foo: 2 }
Correct: C
Although const is used to declare the variable obj, this means that the reference to the object that obj points to cannot be changed. However, the properties within that object can be modified. Therefore, when we update the foo property from 1 to 2, the final value of obj becomes { foo: 2 }.