DEV Community

Avinash Vagh
Avinash Vagh

Posted on • Edited on

Mastering Prototype and Inheritance in JavaScript: A Comprehensive Guide

Blog Goals:

  1. How inheritance makes coding efficient
  2. How do we achieve Inheritance in Js
  3. Object.create() method
  4. Everything in Js is object
  5. Prototype chain
  6. Prototype method available on the constructor function
  7. Difference between proto and prototype
  8. Creating your own array library

What is a prototype?

  • A blueprint
  • An original object from which a new object is created.

What is inheritance?

  • In simple terms, inheritance is the concept of one thing gaining the properties or behaviors of something else.

  • To say A inherits from B, is saying that A is a type of B.

-a Bird inherits from an Animal because a Bird is a type of Animal it has characteristics of every other animal, but other features as well.

Why Inheritance?

  • It allows us to borrow properties and function methods of one object on another object. ( Inheritance )
  • more reusable code How to use Prototypal Inheritance in Js?

There are two ways.

1. Object.create()

2. Constructor functions
Enter fullscreen mode Exit fullscreen mode

additional resources:
https://javascript.info/prototype-inheritance
master the js

Thank you for reading :))

sleeping at 12AM and wake up at 5AM can make you productive in life than any other random schedule

If you like my blog, you can connect with me on LinkedIn & can follow me on Twitter & can checkout my Hashnode blog

Top comments (0)