This article for you to introduce the object-oriented inheritance and how to achieve the batch implementation of object-oriented, interested can refer to Ha, I hope to help you
copy code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> Batch Implementation of object-oriented instance < /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 A () {
parent.apply (this,arguments);
Child.apply (this,arguments);
};
for (var i in Parent.prototype) {
A.prototype[i]=parent.prototype[i];
}
for (var I by method) {
A.prototype[i] = method[i];
}
return A; The
};//parameter is a parent constructor, a child constructor, a child method
var int = extend (person,function (name,age,job) {
This.job = job;
},
{
Showjob:function () {
alert (this.job);
}
}
);
var oc=new int (' chivalrous ', 24, ' work ');
Oc.showjob ();
}
</script>
<body>
<p> start to show the batch implementation object-oriented instance </p>
</body>