JavaScript is different from many other programming languages when it comes to Object-Oriented Programming (OOP). Instead of using classes as its foundation, JavaScript uses prototypes. ES6 introduced classes, but they are just a cleaner way of working with prototypes.

In this blog, I'll explain the topics I learned today.

1. What is a Prototype?

A prototype is a shared object that stores common methods and properties.

Instead of creating a separate copy of the same method for every object, JavaScript stores it once in the prototype, and all objects created from the same constructor or class share it.