This article mainly guides you through the JavaScript design model. it focuses on encapsulation, provides examples to illustrate encapsulation ideas, and analyzes encapsulation in detail. interested friends can refer to JavaScript for reference, it does not support abstract classes and interfaces. JavaScript is also a weak language. In terms of encapsulation types, JavaScript is incapable and there is no need to do more. For the implementation of the JavaScript design pattern, the absence of differentiated types is an eclipse and can be said to be a relief.
From the perspective of design patterns, encapsulation is embodied in encapsulation changes at a more important level.
By encapsulating changes, the stable and easy-to-change parts of the system are isolated. in the process of system evolution, we only need to replace those easy-to-change parts, if these components are encapsulated, they are easy to replace. This guarantees program stability and scalability to the maximum extent.
There are three basic javascript encapsulation modes:
1. use the agreed priority principle to start all private variables _