Home > Article > Web Front-end > Usage analysis of public, private, privileged and static members in JavaScript_javascript skills
The examples in this article describe the usage of public, private, privileged and static members in JavaScript. Share it with everyone for your reference. The specific analysis is as follows:
The following content is excerpted from "JavaScript.DOM Advanced Programming", which is relatively easy to understand. I record it here so that friends who are getting started with Javascript can share it.
1. Since private members and privileged members are inside the function, they will be brought to each instance of the function (that is, each instance created by the constructor will contain a copy of the same private and privileged members , so the more instances, the more memory it takes up).
2. Public prototype members are part of the object blueprint and are applicable to every instance of the object instantiated through the new keyword.
3. Static members only apply to a special instance of the object (this special instance is the constructor itself as a Function object instance).
I hope this article will be helpful to everyone’s JavaScript programming design.