How to simulate a class with a function in the ES5?

ES 5 no class keyword , you can only use the function to simulate the class .

When generating instances, using the new keyword. Properties and methods of a class, may also be defined in the constructor of the prototype object above.


16749735-a583edaf822b2b6e.png

The above code is a simple class, creating a person object constructor out of there own name; age; job attributes , the prototype has a top sayname property.

Guess you like

Origin blog.csdn.net/weixin_34279579/article/details/90892150