Created
July 8, 2012 20:19
-
-
Save jessebeach/3072656 to your computer and use it in GitHub Desktop.
Building objects the IIFE way
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 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