Design patterns·Wrapping and composing
everything is inside one function that returns an object with three methods, and the rest is unreachable from outside.
Module pattern
Also calledrevealing module pattern, namespace object
Wrapping state and functions in a scope and exposing only a chosen surface, giving private members in a language that has no private keyword. It is how encapsulation was done in JavaScript before modules and classes and remains a common shape in plugin and library code. It is worth naming because it is a reminder that encapsulation is a design property, not a language feature.