Comparing the ES5 and ES6 in the prototype class inheritance

ES5: Inheritance:

1.ES5: inheritance inheritance through the prototype chain. Prototype parent class object instance of a subclass, thus prototype object subclass contains links to the parent class prototype object pointer property instance of the parent class of a child class prototype property

2.ES6 inherited the essence is to create an object instance of this subclass, then add to this parent class above (Parent.apply (this))

 

To further reduce the ES6 writing code, and to simplify the logic of the code introduced keyword class. But also in the prototype class implementation on the basis of doing a layer of syntactic sugar, most of its functions, ES5 can do, just let the wording of the new class object prototype of the wording clearer, like object-oriented programming grammar only.

 

Guess you like

Origin www.cnblogs.com/yeanling/p/11225669.html