Created
May 15, 2012 10:06
-
-
Save simme/2700537 to your computer and use it in GitHub Desktop.
Module pattern thingy
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
| var ModuleName = (function ($) { | |
| // Constructor | |
| var module = function () { | |
| // to stuff when "new" is called on us | |
| }; | |
| // Say hello | |
| module.prototype.say = function (name) { | |
| alert('Hello ' + name); | |
| }; | |
| return module; | |
| }(window.jQuery)); // Passing in globals | |
| // USAGE | |
| var sayer = new ModuleName(); | |
| sayer.say('simon'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment