Often see a How to inherit B problem; decide to write, in fact, inheritance is the inheritance of the parents of the attributes and methods, interested friends can refer to ha, I hope to help you
copy the code is as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> Object-Oriented inheritance instance </title>
<script type= "Text/javascript" >
Window.onload = function () {
function parent (age,name) {
This.age = age;
THIS.name = name;
}
Parent.prototype.show = function () {
Alert (' parent method ');
}
function Child (age,name,job) {
Parent.apply (this,arguments);
This.job = job;
}
(function () {
for (var i in Parent.prototype) {
Child.prototype[i]=parent.prototype[i]
}
})();
var B = new Parent (14, ' Knight's Line ');
var a = new Child (15, ' Werewolf ', ' Knight ');
A.show ();
}
</script>
<body>
<p> often see questions about inheritance question a How to inherit B decide to write, in fact, inheritance is the inheritance of the properties and methods of the parent-level </p>
</body>