Which JavaScript Library Has the Most Comprehensiv

2020-05-19 05:53发布

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.

9条回答
冷血范
2楼-- · 2020-05-19 06:34

You should try Classy:

http://classy.pocoo.org/

It is simple and really small but has everything I need when constructing my classes.

查看更多
姐就是有狂的资本
3楼-- · 2020-05-19 06:40

I think Microsoft Ajax implements it just perfectly (with namespaces, inheritance & interfaces etc.)

Sample:

Type.registerNamespace("Demo");

Demo.Person = function(firstName, lastName, emailAddress) {
    this._firstName = firstName;
    this._lastName = lastName;
    this._emailAddress = emailAddress;
}

Demo.Person.prototype = {

    getFirstName: function() {
        return this._firstName;
    },

    getLastName: function() {
        return this._lastName;
    },

    getName: function() {
        return this._firstName + ' ' + this._lastName;
    },

    dispose: function() {
        alert('bye ' + this.getName());
    }
}
Demo.Person.registerClass('Demo.Person', null, Sys.IDisposable);

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
查看更多
聊天终结者
4楼-- · 2020-05-19 06:43

You might also be interested in qooxdoo, a framework for creating rich internet applications (RIAs). It includes a comprehensive OO layer, which aims at being powerful, elegant and fast:

See the following section in the manual, which has all the details: http://qooxdoo.org/documentation/0.8#object_orientation

查看更多
登录 后发表回答