Skip to content

Instantly share code, notes, and snippets.

@simme
Created May 15, 2012 10:06
Show Gist options
  • Select an option

  • Save simme/2700537 to your computer and use it in GitHub Desktop.

Select an option

Save simme/2700537 to your computer and use it in GitHub Desktop.
Module pattern thingy
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