The Prototype Concept
Much of the difference between JavaScript and languages like Java is that OOP in Java is based on a different type of class than in JavaScript. In traditional OOP, a class is a set and any object is an instance of that class or set. However, in JavaScript, the concept of class revolves around the concept of a prototype. Unlike the set concept of class that treats an instance of an object to be a member of the class, the prototype concept treats the named object with all of the properties that all members of the class have. For example, consider the class called Mall.
A Mall object has several characteristics expected in all malls. The following lists what just about any mall has:
A name (Bloomfield Mall)
Shops (butcher, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access