HardMisc Quirks💻 Output Question

Primitive vs Reference Type Variable Mutation

💡

Hint

Consider what happens when you pass a primitive type versus an object to a function and how reassignment affects the original variable

What does this output?

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

Correct Output

John
25

Why this output?

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz