Some months ago, my friend Eduardo Nunes and I started to develop a javascript inheritance library. Maybe you are asking yourself now: "Why another one?" Because all the others we had found weren't exactly as normally needed.

This library is called jsii and it has been very usefull for the projects that I've been working and I really think it can help you. We would appreciate if you test it and give us a feedback.

I will show you here a usage example and, if you are interested on it, you can check out clicking here.


Usage Example

var Shape = Class.extend({
height: 0,
width: 0,
init: function(height, width) {
this.height = height;
this.width = width;
},
info: function() {
alert("I have height = " + this.height + " and width = " + this.width);
}
});

var Rectangle = Shape.extend({
});

var Square = Rectangle.extend({
init: function(size) {
this._super().init(size, size);
}
});

var rectangle = new Rectangle(5, 10);
var square = new Square(10);

rectangle.info(); // it will alert => I have height = 5 and width = 10
square.info(); // it will alert => I have height = 10 and width = 10

Labels: , , ,