• Shaarli
  • Tag cloud
  • Picture wall
  • Daily
  • RSS
  • Login
4253 shaares
Filters

Just JavaScript - The Prototype Mechanism

QRCode

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.

http://www.i-programmer.info/programming/javascript/8025-just-javascript-the-prototype.html
August 1, 2017 at 12:17:08 PM EDT *
javascript
FILLER
Shaarli · The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community · Documentation
Fold Fold all Expand Expand all Are you sure you want to delete this link? Are you sure you want to delete this tag? The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community