Skip to main content

Command Palette

Search for a command to run...

Prototypes and prototype chaining in Javascript

Published
1 min readView as Markdown
Prototypes and prototype chaining in Javascript

Prototype:-

Every object in javascript has a built-in property,which is called its prototype. The prototype is itself an object, so the prototype will have its own prototype, making what's called a prototype chain.In javascript, every function and object has a property named prototype by default.

For example the function,

Person () {this.name = 'jyoti',this.age = 20} const Person = new Person(); // checking the prototype value console.

Prototype chaining:-

Prototypes are the mean of inheritance in javascript. The prototype of an object would also have a prototype object. This continues until we reach the top level when there is no prototype object. This is called prototype chaining in javascript.