After playing with a dozen different JavaScript Libraries such as Prototype, jQuery, YUI, just to name a few, I found every different library has a different way of simulating some sort of Class Hierarchy and provide some sort of Class Inheritance support. (Other than jQuery) Other than being very annoyed that when you create a new class, it has to be library dependent, unless you do the plain old way.
I'm wondering which library offers the best support for class inheritance in general and why.
I hope maybe one day JavaScript Library authors can agree on one style for Class creation and inheritance.
When it comes to inheritance, JavaScript only has one construct: objects. Each object has a private property which holds a link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype.
Inheritance enables you to define a class that takes all the functionality from a parent class and allows you to add more. Using class inheritance, a class can inherit all the methods and properties of another class. Inheritance is a useful feature that allows code reusability.
The most important difference between class- and prototype-based inheritance is that a class defines a type which can be instantiated at runtime, whereas a prototype is itself an object instance.
I found out there is a Javascript Framework modeled after Ruby:
Js.Class
Another good one is:
Joose-js (modeled after moose (perl) )
I prefer Josse, because it seems to be more actively developed, and the syntax looks neat too!
Any thoughts??? (Maybe this should be another question??)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With