You do not know the JS series (41) - in class JS

For a long period of time, JS approximate only some kind of syntax elements, such as new and instanceof, but later in the ES6 added some elements, such as the class keyword. This is not meant to actually type it in JS? In simple terms: It is not
 
Since the class is a design pattern, it is possible to realize the function approximated by class methods. In order to meet the most common requirements for class design, JS provides syntax similar class

Although there are similar type of grammar, but JS mechanism seems to have been designed to prevent you from using class mode. Under similar class appearance, JS mechanism and in fact completely different class. Syntactic sugar and JS libraries are widely used trying to cover up this reality, but sooner or later you will face it: language classes and other classes in JS are not the same.

In the software design class is an optional mode, you need to decide whether to use it in JS. Since many software developers are very fond of class-oriented design, the remainder of this chapter describes how to implement classes and the total number of problems in JS, we learn together

Guess you like

Origin www.cnblogs.com/wzndkj/p/12617304.html