🟡 Medium'this' Binding💻 Output Question

new binding creates fresh object

💡

Hint

new binding: each call creates a new object. Own properties are per-instance. Prototype properties are shared across all instances.

What does this output?

function Animal(name) {
  this.name = name;
  this.type = 'animal';
}

Animal.prototype.speak = function() {
  return this.name + ' speaks';
};

const a = new Animal('Leo');
const b = new Animal('Mia');

console.log(a.name);
console.log(b.name);
console.log(a.speak());
console.log(a.type === b.type);
console.log(a.speak === b.speak);

Correct Output

Leo
Mia
Leo speaks
true
true

Why this output?

Explanation: new creates fresh objects, each with own name and type properties. prototype methods are shared — a.speak === b.speak is true (same function reference on the prototype).

Key Insight: new binding: each call creates a new object. Own properties are per-instance. Prototype properties are shared across all instances.

More 'this' Binding Output Questions

🟡 MediumMethod extracted from object→🟡 MediumArrow function this→🔴 Hardthis in nested function→🔴 Hardbind creates new function→

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz