Junior JavaScript

What is prototypal inheritance?

JavaScript objects inherit properties and methods from other objects through

prototypes. This allows reuse of methods and shared behavior.

Example:

const parent = { greet() { console.log("Hello"); } };

const child = Object.create(parent);

child.greet(); // Hello

More from JavaScript Tutorial

All questions for this course