Skip to content

Instantly share code, notes, and snippets.

@thekingofspain
Last active August 29, 2015 14:05
Show Gist options
  • Save thekingofspain/f28431121da08c1487dd to your computer and use it in GitHub Desktop.
Save thekingofspain/f28431121da08c1487dd to your computer and use it in GitHub Desktop.
javascript-module-pattern
var module = (function () {
// private variables and functions
var foo = 'bar';
// constructor
var module = function () {
};
// prototype
module.prototype = {
constructor: module,
something: function () {
}
};
// return module
return module;
})();
// http://briancray.com/posts/javascript-module-pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment