Created
August 23, 2012 15:13
-
-
Save jeffsheets/3437635 to your computer and use it in GitHub Desktop.
JS Module Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From https://github.com/sjurgemeyer/GR8-US-2012/blob/master/Mobile-and-Grails-ZachLendon/Mobile-and-Grails-ZachLendon.pdf | |
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; | |
})(); | |
var my_module = new module(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment