JavaScript Prototype

Summary: in this tutorial, you’ll learn about the JavaScript prototype and how it works under the hood.

Introduction to JavaScript prototype

In JavaScript, objects can inherit features from one another via prototypes. Every object has its own property called a prototype.

Because the prototype itself is also another object, the prototype has its own prototype. This creates a something called prototype chain. The prototype chain ends when a prototype has null for its own prototype.

Suppose you have an object person with a property called name:

let person = {'name' : 'John'}Code language: JavaScript (javascript)

When examining the person object in the console, you’ll find that the person object has a property called prototype denoted by the [[Prototype]]: