Just JavaScript - The Prototype Mechanism
Using Prototypes
You can think of the prototype mechanisms as providing some sort of inheritance - but it certainly doesn't bring with it any of the other pillars of OOP, encapsulation and polymorphism say. It is a much simpler and much more direct mechanism to make code sharing possible.
If you have a single object then there isn't much practical advantage in designing a prototype object for it. On the other hand having a prototype object with all of the methods that the object is using does provide an organization. The object then has just the instance variables and the methods are all provided by the prototype. If things change and you need a second object, or more objects, then the prototype provides an easy solution.
August 1, 2017 at 12:17:08 PM EDT
*
FILLER