JavaScript:

Non-classical inheritance




It's easy to mimic classes

 in JavaScript...


Classical inheritance libs:

  • Class.js
  • Base2.js
  • ...

but none of those libraries has become a defacto standard

Classical way






Inheritance hierarchies are trouble





Favor object composition over class inheritance
The Gang of Four, "Design Patterns"




Three kinds of prototypal OO




DELEGATE PROTOTYPE

  • Shared methods


Delegation





Cloning / concatenation

  • Great for default state
  • Mixins


MIXINs/default state





Functional inheritance

  • Great for encapsulation / privacy
  • Is an alternative to a constructor / init function

Function prototypes






STampit by Eric Elliott

  • method
  • state
  • enclose

Links

JavaScript:Non-classical inheritance

By Yauheni Zara

JavaScript:Non-classical inheritance

  • 802