class instance interface abstract-class extends implements private protected public static const constructor super read-only friendly-method event |
SuperTo access base class's property, the keyword "super" is used. It allows accessing the constructor, methods and attributes. As super is a reserved word in Javascript, most editor will indicate it as a special word. var ClassA=Class({
init:function(a){
this._a=a;
},
foo1:function(){
return this._a;
},
_a:false
});
var ClassB=Class.extends(ClassA)({
init:function(a1,a2){
this.super(a1); //call base class constructor
this._a=a2;
},
foo1:function(){
//access base class method
return this.super.foo1()+this._a;
},
_a:false //attr wont conflict attr in base class
});
var classB=new ClassB(3,4);
classB.foo1();
//> 7
|