Created
February 18, 2014 15:35
-
-
Save octavian-nita/9073252 to your computer and use it in GitHub Desktop.
JavaScript module pattern (inspiration: TypeScript, json2.js by Douglas Crockford)
This file contains 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 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