1. Combination inheritance
First of all, in essence, combined inheritance = prototype chain + constructor inheritance.
1. The concept of prototype and prototype chain
There will be a prototype pointer inside each constructor, pointing to a prototype object, and this prototype object also has a constant pointer pointing back to the constructor.
When creating an object
2. Prototype chain
Advantages: Partial function reuse
Disadvantages: (1) All attributes and methods of the parent class (whether private or shared attributes) are regarded as prototypes by the subclass. (2) Unable to pass parameters to the parent class
3. Constructor inheritance
Advantages: you can pass parameters to the parent class
Disadvantages: Without the use of the prototype chain, it is impossible to achieve function reuse
4. Combinatorial inheritance
Private data is inherited through the constructor, and shared data and methods are inherited through the prototype chain.
Second, parasitic combined inheritance
First, in essence, parasitic combined inheritance = prototype inheritance + parasitic inheritance.
1. Prototype inheritance
2. Parasitic inheritance
3. Parasitic combined inheritance
Three, combined inheritance VS parasitic combined inheritance
In fact, there is only one difference between combinational inheritance and parasitic combinational inheritance. Is the prototype of the subclass directly inheriting the prototype of the parent class?