JSVerse
Advanced JavaScript / Classes

Classes

Syntax for building objects with shared behavior, on top of the same prototype chain.

A `class` is mostly a cleaner way to write what prototypes already do: methods defined on a class live on its `prototype`, shared by every instance rather than copied onto each one. `extends` links a subclass's prototype to its parent's, and `super()` calls the parent constructor so inherited fields get set up correctly.

Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
State
Step through — the console panel shows what's happening
Why?

Dog.prototype's own prototype is Animal.prototype. Dog defines its own speak, so that's found first — if it didn't, the lookup would continue up to Animal's speak.