Hello,
After looking for a simple Class system in JavaScript, and looking at all the horrible libraries, forced upon terrible syntax, cluttered objects and prototypes... I'd like to introduce a simple alternative.
This is a very bare-bones, and yet one of the more powerful class systems in JavaScript. Built on-top of Object.create
and prototype
inheritance using the methods that everyone suggests is the best way to do classes in JavaScript ported over to a nicer syntax.
It doesn't clutter the properties or the prototype
aside from a single method which is extends
, and even this method is sugar and not required!
Check out zoo.js
for an in-depth example of how to use Class
. No matter how deep down the rabbit hole you go, it should keep references so you can do instanceof
checks on children of a parent of a grand-parent and so forth.