What I am trying to do is inherit the id
and name
from the TField
and override the render
function of the TField
. I want to know if this is the stardard way to implement inheritance in JavaScript.
var TField=function(jData)
{
this.id=jData.id;
this.name=jData.name;
this.attributes=jData.attributes;
this.render=function(){
alert('TField render.');
};
};
var TChildField=function(jData)
{
var t= new TField(jData);
t.render=function(){
alert('TChildField render.');
}
return t;
}
var tobj={id:"1",name:"test",attribute:{}};
var c= new TChildField(tobj);
alert(c.id);
alert(c.name);