subject:รูปแบบการสืบทอด class
syntax:function parentClassName ( param1, param2, ..., paramN )
{
property;
method;
}
function childClassName ( param1, param2, ..., paramN )
{
property;
method;
}
childClassName.prototype = new parentClassName ( );
content:ใช้ในการสืบทอดคลาส
example:function Person ( oName )
{
this.name = oName;
this.getName = function ( )
{
return this.name;
}
}
function Man ( oName, oAge )
{
this.name = oName;
this.age = oAge;
this.sex = "Man";
this.getAge = function ( )
{
return this.age;
}
}
var panda = new Man ( "Function", 24 );
alert ( panda.getName ( ) );
alert ( panda.getAge ( ) );