I am writing some objects (classes I guess) in javascript. Class B inherits from Class A. Class A has a method called isValid, and class B overrides that method. I am using the YUI extend function to have Class B extend Class A.
A = function(){
}
A.prototype = {
isValid:function(){
/* Some logic */
return booleanValue;
}
}
B = function(){
}
YAHOO.lang.extend(B, A,{
isValid:function(){
// call class A's valid function
// some more logic for class B.
return booleanValue;
}
});
What I want to be able to do is call Class A's isValid function inside class B's isValid function. The question is, can I access class A's isValid method from class B's isValid method? I know that you can access class A's constructor from inside Class B's constructor with the following line
this.constructor.superclass.constructor.call(this,someParam);
Is something similar possible for methods? If not, what is a good practices for doing this? Currently I am making a helper method called inside the super class' isValid method
A.prototype = {
a_isValid:function(){
// class A's is valid logic
return booelanValue;
},
isValid:function() {return this.a_isValid();}
}
Then I can call the a_isValid function from class B. This does work for me but I would prefer to call the super class' isValid function directly if possible.