function update(obj: {count: number}) { obj.count += 1; } const a = {count: 0}; update(a); update({count: 0}); console.log(a.count);
The function update increments the count property of the passed object.
When called with a, it modifies a.count from 0 to 1.
When called with a fresh object literal {count: 0}, it modifies that temporary object, but it is discarded immediately.
Therefore, a.count remains 1 after both calls.
const obj1 = {value: 10}; const obj2 = obj1; obj2.value = 20; console.log(obj1.value);
Both obj1 and obj2 reference the same object in memory.
Changing obj2.value changes the shared object, so obj1.value also reflects the change.
function mutate(obj: {x: number}) { obj = {x: obj.x + 1}; } const original = {x: 5}; mutate(original); console.log(original.x);
Inside the function, obj is reassigned to a new object. This does not change the original object passed in.
The original object remains unchanged because the function only changes its local parameter reference.
Option A uses invalid syntax b: 2 if true which is not allowed in object literals.
Options A, B, and D use valid JavaScript/TypeScript syntax for conditional properties.
result?let base = {count: 1}; let copy = base; copy.count = 2; copy = {count: 3}; base.count = 4; const result = copy.count + base.count;
base and copy initially point to the same object with count: 1.
After copy.count = 2, both see count: 2.
Then copy is reassigned to a new object {count: 3}, but base still points to the original object.
Then base.count = 4 changes the original object.
So copy.count is 3, base.count is 4, sum is 7.