1. Methods live on .prototype
A method written in the class body is placed on Animal.prototype and shared by all instances.
speak() { return this.name + " makes a sound" }Typorithm · medium
Step 1 of 8 · intro card
Prototypes & Classes
ES class syntax is sugar over prototypes. Methods in a class body live on Class.prototype and are shared, extends sets up the prototype chain between subclass and parent, and super calls the parent method. Under the hood it is still prototype-based.
A class declaration creates a constructor function plus a .prototype object. Methods you write in the class body are not copied onto each instance — they are placed on Class.prototype and shared by every instance via the prototype chain.
extends does the wiring: it sets the subclass's .prototype [[Prototype]] to the parent's .prototype, so Object.getPrototypeOf(Dog.prototype) === Animal.prototype. That single link is the entire inheritance mechanism.
Inside a subclass, super.method() reaches up to the parent's prototype to call its version, and super(...) in a constructor runs the parent constructor. None of this is new machinery — it is the prototype chain with friendlier syntax.
Class methods live on Class.prototype, shared across instances.
extends links Sub.prototype to Parent.prototype.
super reaches the parent method; it is all prototypes underneath.
class Animal {
constructor(name) { this.name = name }
speak() { return this.name + " makes a sound" }
}
class Dog extends Animal {
speak() { return super.speak() + " (woof)" }
}
typeof Animal.prototype.speak === "function" // true — method is shared
Object.getPrototypeOf(Dog.prototype) === Animal.prototype // trueConnect each part of the code to the concept before you type.
A method written in the class body is placed on Animal.prototype and shared by all instances.
speak() { return this.name + " makes a sound" }extends sets Dog.prototype's [[Prototype]] to Animal.prototype, building the inheritance chain.
class Dog extends Animal {super.speak() invokes the parent's method found on Animal.prototype.
super.speak()The method really lives on Animal.prototype, proving class methods are prototype-based and shared.
typeof Animal.prototype.speak === "function" // true — method is sharedextends wires Dog.prototype's [[Prototype]] to Animal.prototype under the hood.
Object.getPrototypeOf(Dog.prototype) === Animal.prototype // trueRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.