Object: Contains the collection of properties and methods!
01. Object-Oriented is a kind of programming idea!
02. In JS, it is through the prototype object (prototype) to achieve object-oriented programming!
Note the point:
1. All objects have a constructor attribute, which points to the constructor!
document.write (stu1.constructor==student+ "<br/>");
2. When creating a constructor, there is a property called prototype!
This prototype points to the prototype object created by the constructor!
3. Each object has a __proto__ attribute pointing to the prototype object (Student.prototype)
4. A prototype object is an object that creates shared properties and methods for other objects!
5.Object not pointing, the value of __proto__ is null
var stu1={};
document.write (stu1.prototype+ "<br/>"); Only constructors have
document.write (stu1.__proto__+ "<br/>"); Default Execution Object
Prototype chain:
01. One prototype object is an instance of another prototype Object! The little black Dog is an example of a black dog! A black dog is an example of a dog!
02. The related prototype chain layer progression, constitutes the example and the prototype object chain!
Two ways to inherit the implementation:
01. Using the prototype chain
Dog.prototype=new Animal ();
02. Using Borrowed constructs
Animal.call (This, ' dog '); You can also pass parameters directly
Combination of inheritance: is the appeal of the two ways to integrate the use!
Prototype chain diagram:
JS Object-oriented