Research: Prototypes - imkarin/bloktech GitHub Wiki

Prototypes in JavaScript

Everything in JavaScript, arrays, functions etc. is an object. All objects have a prototype, Object.prototype, from which they inherit properties and functions (methods). By default, this prototype contains all kind of methods that you can run on your object, for example hasOwnProperty. Prototypes are like the blueprints for objects. Through the JavaScript constructor function (classes in ES6), you can build your own blueprints for objects, assigning your own properties and methods to them.

If you call a method or property on an object but it's not on the object itself, it will look for this method or property through the prototypical chain (__proto__ in console).

An example of where this could be useful, is if you want to create multiple objects with similar properties, but want to add a specific property or method to only 1 of them.

Never modify the prototypes of standard JavaScript objects, only your own prototypes.

How will I use this?

I could use prototypes by working with JavaScript classes to create users. Every user has to have a specific set of properties like name, age, description, profilepicture, and likeStatus etc. The JS 'user' class/constructor will create a prototype, that serves as a blueprint for every new user object.

classes-prototype

Sources