Skip to content

Instantly share code, notes, and snippets.

@jessebeach
Created July 8, 2012 20:19
Show Gist options
  • Save jessebeach/3072656 to your computer and use it in GitHub Desktop.
Save jessebeach/3072656 to your computer and use it in GitHub Desktop.
Building objects the IIFE way
var Speaker = (function () {
function Hello() {
}
Hello.prototype.repeatAfterMe = function (message) {
return message || 'fine, be that way';
};
return Hello;
}());
var a = new Speaker();
a.repeatAfterMe('hi'); // 'hi'
a.repeatAfterMe(); // 'fine, be that way'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment