Home >Web Front-end >JS Tutorial >Javascript class definition syntax, introduction to private members, protected members, static members, etc._javascript skills
In fact, in popular terms, a class is the template of an object. In order to enhance the OO features of JS, inspired by the mootoos framework, we can use a JSON object to describe the template of this object. In this template we can simulate private members, protected members, and static members.
This is a class definition syntax simulated in JS. Class in the code is a custom function that accepts two parameters. The first parameter is the class name and the second parameter is a JSON for an object. template. In this JSON object, the fields "extend", "initialize", and "static" are some predefined keywords, and their meanings are similar to traditional class-based OO languages. The field accessabe is used to describe the accessibility of an object member. The value is ("private", "protected", "public"). These keywords are specially processed in the Class function so that the modified members have corresponding access rights.