Skip to content

Instantly share code, notes, and snippets.

@octavian-nita
Created February 18, 2014 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save octavian-nita/9073252 to your computer and use it in GitHub Desktop.
Save octavian-nita/9073252 to your computer and use it in GitHub Desktop.
JavaScript module pattern (inspiration: TypeScript, json2.js by Douglas Crockford)
var Module;
(function (Module) {
'use strict';
var Greeter = (function () {
// Define the Greeter class:
function Greeter(message) {
this.greeting = message;
}
Greeter.prototype.greet = function (name) {
return this.greeting + ' ' + name;
};
return Greeter;
})();
// Exports:
Module.Greeter = Greeter;
})(Module || (Module = {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment