HardMisc Quirks💻 Output Question

Pass by Value and Object Mutation

💡

Hint

Think about what happens when you reassign a variable inside a function, and how it affects the original variable outside the function

What does this output?

function change(obj) { obj = { age: 30 }; }
let person = { name: 'John', age: 25 };
console.log('Before:', person);
change(person);
console.log('After:', person);

Correct Output

Before: { name: 'John', age: 25 }
After: { name: 'John', age: 25 }

Why this output?

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz