Topic comments
This topic belongs to JavaScript more difficult to understand the knowledge point, the knowledge is also very abstract abstruse, belong to the JavaScript object-oriented thinking category, if there is no object-oriented programming thinking students, must be stumped, even if there is some OOP students to answer it is also more laborious , not 1:30 will be able to speak clearly. But the interviewer asked, stating that he is skilled, in a more professional terms to answer the good, this will be more concise. ideas for solving problems what the prototype is.
In JavaScript, a prototype is a prototype object that represents the relationship between types. What the prototype chain is.
JavaScript is the object of all things, objects and objects are also related, and not isolated. An inheritance relationship between objects, in JavaScript by prototype objects to the parent object, until the object is pointed, so that a prototype is pointed to the chain, and the jargon is called the prototype chain. Give an example to explain
Student→person→object, the student inherits the human, the human inherits the object class
Code
<span style= "FONT-SIZE:14PX;" >varperson=function () {this.age= "anonymous"};
Varstudent=function () {};
Creates an inheritance relationship, prototype an instance object student.prototype=new person ();</span>
Prototype API diagram
Thin map