Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Set up prototypal inheritance by creating a Dog constructor that calls Animal via Animal.call(this, name), then links prototypes with Object.create(Animal.prototype). This establishes the prototype chain so Dog instances inherit Animal methods while adding their own.
JavaScript property lookup walks the prototype chain. When dog.speak() is called, the engine checks dog, then Dog.prototype, then Animal.prototype, finding the method there.
Updated Feb 2026