Home  >  Article  >  Web Front-end  >  There are 4 different types of properties and methods of JavaScript objects_js object-oriented

There are 4 different types of properties and methods of JavaScript objects_js object-oriented

WBOY
WBOYOriginal
2016-05-16 18:31:52865browse

The first type is the private type mentioned earlier. Its characteristic is that it is completely inaccessible to the outside world. To access them, you can only use specific getters and setters.
The second type is a dynamic public type. Its characteristic is that it can be accessed by the outside world, and each object instance holds a copy, and they will not affect each other.
The third type is a static public type, or commonly called a prototype attribute. Its characteristic is that each object instance shares a unique copy, and its modifications will affect each other.
The fourth type is class attribute, which is characterized by being an attribute of the type rather than an attribute of the object instance. It can also be accessed when the object is not constructed. The following examples illustrate the characteristics and differences of these four attribute types: Four attributes of type

Copy code The code is as follows:




Example 21.3






Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn