最終更新:2021-02-25 (木) 23:50:52 (1162d)
Revealing Module Pattern
Top / Revealing Module Pattern
https://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript
概要
- the most famous and most popular of the Module Pattern variants.
- Rename public functions without changing function body.
- Change members from public to private or vice versa by modifying a single line, without changing the function body.
- 違い
- satisfies three additional conditions in addition to those in the original:
- All members, whether public or private, are defined in the closure.
- The return object is an object literal with no function definitions. All right hand side expressions are closure variables
- All references are via the closure variables, not the return object.
var myNameSpace = function(){ var current = null; function init(){...} function change(){...} function verify(){...} return{ init:init, set:change } }();