Course contentsShow
← JavaScript
Lesson 715 of 2,72317. Prototypes and InheritanceFree lesson

How 'new' Connects prototype to __proto__

When calling 'new Func()', the new object's __proto__ is set to Func.prototype.

How 'new' Connects prototype to proto

You'll learn the exact mechanism that links a constructor function's prototype property to a newly created object's internal [[Prototype]] (accessible via __proto__).

The Connection Mechanism

When you call a function with the new keyword, JavaScript performs several steps behind the scenes. One crucial step is establishing the prototype relationship: the new object's __proto__ is set to point to the constructor function's prototype property.

This is the "magic" that makes prototype inheritance work. The constructor function has a prototype property (an object), and every new instance gets its internal [[Prototype]] linked to that same object.

How It Works

function Animal(name) {
  this.name = name;
}

// The function has a prototype property
Animal.prototype.speak = function() {
  return `${this.name} makes a sound`;
};

// When we use 'new':
const cat = new Animal('Whiskers');

// The 'new' keyword sets cat's __proto__ to Animal.prototype
console.log(cat.__proto__ === Animal.prototype); // true
console.log(Object.getPrototypeOf(cat) === Animal.prototype); // true

// Now cat can access methods on Animal.prototype
console.log(cat.speak()); // "Whiskers makes a sound"

The new keyword acts as the bridge-builder. Without new, this connection wouldn't happen automatically—your object would just have the default Object.prototype as its [[Prototype]].

Key Takeaway: The new keyword automatically sets a new object's __proto__ (internal [[Prototype]]) to reference the constructor function's prototype property, establishing the prototype chain for inheritance.