By object-oriented function package to give a class,
Nature or function of a class: Remarks
1 for each class ( function ) born with a prototype attributes, the prototype is an object, the object which has a Construction ( Constructor ) attribute, the attribute value is the class itself.
2 All of our new class, when, in fact, is calling its constructor. Constructor is private property, constructor of this is an instance of an object.
3 born with one on each object the __proto__ , point to the class prototype.
function Person(){
}
var zhangsan=new Person;
console.dir(zhangsan)
console.log(zhangsan.__proto__==Person.prototype)
Prototype __proto__
- prototype is a class or function, the __proto__ is subject
- Prototype is a storage mechanism, __proto__ is to find mechanisms
Zhangsan.name
Zhangsan this object first look at the name is private, is used directly, instead of on the adoption of __proto__ go on its class prototype look, there is the direct use, not to keep looking up, until you find the base class Object , not that undefined , there is the direct use. This discovery mechanism called the prototype chain.
Special Function
1 class
2 function
3 objects
4. Each function is born with a return value, return of what it is, if no return is undefined