Javascript Inheritance

01
ChatGpt explaination of basic [[Prototype]]
, used to be __proto__
now depreciated, but in tutoriala and on an instance of class there is .__proto__
and stores the methods
from it's Parent
class's .prototype
just like .prototype
class Dog { bark(){ return 'barking' } } const fido = new Dog() fido
- fido doesn't have a bark method directly on it.
- Instead, fido.__proto__ (or Object.getPrototypeOf(fido)) points to Dog.prototype, where bark lives.
- So fido.bark() works because JavaScript looks up the prototype chain and finds it there.
⛓️ Think of It Like a Chain When you call a method on an object:
- JS looks on the object itself.
- If it doesn't find it, it goes to the object's prototype.
- If still not found, it keeps going up the chain until it hits null.
So you're not seeing methods directly on instances because they're not there — they're on the prototype.
We use promises when we need to wait for information or data