First, the prototype chain inheritance
functionfunctionnew
The object child's prototype property points to an instance of the parent object, so that an instance of the child object is accessed through the prototype chain to the properties, methods, etc. defined by the parent object construction.
second, the use of apply, call method
JS in the call and apply can be inherited, the only point of a different parameter, Func.call (FUNC1,VAR1,VAR2,VAR3) corresponding to the application of the wording: Func.apply (Func1,[var1,var2,var3]).
Same point: The first parameter, this is the same, refers to the current object.
Different points, the second parameter is not the same, call is a list of parameters, apply is an array (arguments can also)
<script type= "Text/javascript" >functionPerson (name,age,love) { This. name=name; This. age=Age ; This. love=Love ; This. say=functionsay () {alert ("Name:" +name); } } //Call mode functionStudent (name,age) {Person.call ( This, Name,age); } //Apply Method functionTeacher (name,love) {person.apply ( This, [Name,love]); //person.apply (this,arguments);//With the same effect as the previous sentence, arguments } //the similarities and differences between Call and aplly: //1, the first parameter, this is the same, refers to the current object //2, the second parameter is different: Call is a list of parameters, and apply is an array (arguments can also) varPer=NewPerson ("Wu Feng Lou", 25, "Wei-screen");//output: "Wu Feng Building"Per.say (); varstu=NewStudent ("mansion", 18);//output: "Mansion"Stu.say (); varTea=NewTeacher ("Narl", 16);//output: "Narl"Tea.say (); </script>
Iii. inheritance between object instances
Originally from: http://www.jb51.net/article/20431.htm
Three ways in which JavaScript implements inheritance