Introduction
Prototypes are the technique by which JavaScript objects inherit features from one another.
Prototypes are a flexible and robust feature that allows you to reuse code and combine objects.

Every function includes a prototype object by default. The prototype object is a specific type of enumerable object that can have additional characteristics shared across all instances of its function.
Object prototyping in javascript has some essential uses like finding properties and methods of an object, implementing inheritance, etc.
Let’s learn about object prototypes in-depth.
Also See, Javascript hasOwnProperty
JavaScript Prototypes
Let’s understand the Prototypes with the help of an example:
function Company() {
this.fname = 'Coding';
this.lname = 'Ninjas';
}
let c1 = new Company();
c1.city = 'Delhi';
console.log(c1.city);
let c2 = new Company();
console.log(c2.city);
Output:

As you can see in the above example, the city property is attached to the c1 instance. However, the c2 instance will not have city property because it is defined only on the c1 instance.
So the problem that arises here is that we cannot add a new property to an existing object constructor.
To solve this problem, we use object prototypes.
Prototype: A prototype is an object associated with all functions and objects in JavaScript by default. The function's prototype property is accessible and editable, and the object's prototype property is hidden.
By default, every function includes a prototype object.
So, use the function's prototype property in the above example to have city properties across all the objects, as shown below:
function Company() {
this.fname = 'Coding';
this.lname = 'Ninjas';
}
Company.prototype.city = 'Delhi'
let c1 = new Company();
console.log(c1.city);
let c2 = new Company();
console.log(c2.city);
Output:

With the help of the prototype, we can easily access the city property with any of the instances we create.
Note: The property that points to an object's prototype is not called prototype. Although its name isn't standard, all browsers use __proto__ in practice. The Object.getPrototypeOf() method is the most common technique to get an object's prototype.