Skip to content

Instantly share code, notes, and snippets.

@deavial
Forked from ShMcK/JavascriptModulePatterns
Created June 3, 2016 03:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Javascript (ES5) Module Patterns
'use strict';
// 1. Revealing Module Pattern
var revModule = function (param) {
return {
// public
funk: funk
};
// private
function funk () {
return param;
}
}();
// 2. Revealing Prototype Pattern
var revProto = function () {
// variables
var x = 42;
};
revProto.prototype = function () {
return {
// public
getX: getX
};
// private
function getX(num) {
return num;
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment