Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unraveling JavaScript Prototypes

Unraveling JavaScript Prototypes

This is the presentation from JSPoland's talk on unraveling JavaScript prototypes. It explains JavaScript objects and prototypes.

If you need a copy of this PPT to learn it with animation, send me an email at [email protected]

Dhananjay Kumar

November 20, 2024
Tweet

More Decks by Dhananjay Kumar

Other Decks in Education

Transcript

  1. Objects p1 and p2 are CONSTRUCTED from the Product function

    but LINKED to the Product.prototype object.
  2. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2
  3. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2
  4. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2
  5. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2
  6. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2 constructor
  7. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2 constructor
  8. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2 constructor
  9. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2 constructor __proto__ __proto__
  10. Product rating =9 prototype name= Pen price = 10 name=

    Book price = 20 constructor constructor p1 p2 constructor __proto__ __proto__
  11. rating =9 name= Pen price = 10 name= Book price

    = 20 rating = 90 p1 p2 __proto__ __proto__ Read in the prototype chain
  12. Read in prototype chain • Reads in the current object

    • If it does not find it goes to the object’s __proto__ object • It goes further up to the prototype chain if it does not find it. • If it does not find it in Object.prototype returns undefined