Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active January 7, 2016 09:56
Show Gist options
  • Select an option

  • Save stormwild/4518440 to your computer and use it in GitHub Desktop.

Select an option

Save stormwild/4518440 to your computer and use it in GitHub Desktop.

References:

JavaScript-Module-Pattern-In-Depth

Analysis of Js Module Pattern

var MODULE = (function (my) {
    var _private = my._private = my._private || {},
        _seal = my._seal = my._seal || function () {
            delete my._private;
            delete my._seal;
            delete my._unseal;
        },
        _unseal = my._unseal = my._unseal || function () {
            my._private = _private;
            my._seal = _seal;
            my._unseal = _unseal;
        };
     
    // permanent access to _private, _seal, and _unseal
     
    return my;
}(MODULE || {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment