I wanted to inherit the family property inheritance, like in real life. . . . You inherited your father's wealth, in addition to having your father's wealth, you also have your own original wealth
Use code to achieve it
The figure, display sub-category (name = "son" is a subclass) inherits the parent class (name = "Father" is the parent class) wealth, and their wealth is still there, who inherited who is the successor parent
Why name attribute is not inherited in the program in the same field names will subclasses rewrite , which is redefined name
Js said here about the es6 extends inheritance,
He says extends inheritance must say es5 and before implementation inheritance
The principle here explain
First, create a constructor Parent and Children (the call for new constructor)
Use Parent.call (this) in Children constructor function, in order to inherit the properties Parent constructor. . . Here to study carefully what method do not understand the call
Here to prototype prototepy Children's assignment is to get new Parent Parent prototype method under then why not directly children.prototype = Parent.prototype assignment object stored in the address of the heap, so to change the assignment of prototype prototype Parent children went back to change with
Finally, why add the assignment to the next round of the method Children add back Think assignment
Here is the class inheritance:
Exactly the same output. . . class se6 and extent is se5 achieve constructors and inheritance of syntactic sugar
But to achieve different concept of inheritance is the same all the way language implementation inheritance. . . In order to inherit all object properties and object methods of the parent class to make lay a solid foundation of object-oriented flexibility. . .