Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> batch Implementation of object-oriented instances </title>
<Script type = "text/javascript">
Window. onload = function (){
Function Person (name, age ){
This. name = name;
This. age = age;
}
Person. prototype. showName = function (){
Alert (this. name );
};
Function extend (parent, child, method ){
Function (){
Parent. apply (this, arguments );
Child. apply (this, arguments );
};
For (var I in parent. prototype ){
A. prototype [I] = parent. prototype [I];
}
For (var I in method ){
A. prototype [I] = method [I];
}
Return;
}; // The parameter is a parent-level constructor, a Sub-Level constructor, and a sub-level method.
Var int = extend (Person, function (name, age, job ){
This. job = job;
},
{
Showjob: function (){
Alert (this. job );
}
}
);
Var oc = new int ('knight ', 24, 'work ');
Oc. showjob ();
}
</Script>
</Head>
<Body>
<H1> Object-oriented Inheritance instance <P> start to show instances that implement object-oriented operations in batches </p>
</Body>
</Html>