Lesson 23 of 55
javascriptPrototype Chain & Inheritance
10 mins
Course progress42%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 23 of 55
javascript10 mins
Keep these ideas in mind as you work through the lesson.
Every object has an internal [[Prototype]] (accessible via Object.getPrototypeOf).
const animal = { eats:true };
const rabbit = Object.create(animal);
rabbit.jumps = true;
console.log(rabbit.eats); // true – found on prototype
Object.prototype.toString, Array.prototype.map.Object.prototype.log = function(){ console.log(this); };
({a:1}).log(); // {a:1}
(Use with caution – augmenting native prototypes can break libraries.)