01
Overview
JS uses prototypal inheritance. Every object has a prototype (__proto__). Property lookup follows the chain. Object.create(proto) creates with specific prototype. ES6 class is syntactic sugar over prototypes. Use class for clarity, Object.create for prototypal patterns.
bash
class Animal{constructor(n){this.name=n;} speak(){return this.name;}}
class Dog extends Animal{speak(){return super.speak()+" woof";}}
const d=new Dog("Rex"); d.speak(); // Rex woof02
Best Practices
Prefer class syntax over direct prototype manipulation. Use extends for inheritance, super to call parent. Check with instanceof. Use Object.create for prototypal OO without classes. Avoid __proto__ (use Object.getPrototypeOf). Prefer composition over deep inheritance.
Ready to try Prototypes & Inheritance?
Visit the official site for the latest version and full documentation.
Visit Prototypes & Inheritance