Created
April 25, 2011 21:12
-
-
Save gf3/941238 to your computer and use it in GitHub Desktop.
An Example Class
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
function User( options ) { | |
(this.options = options || {} ).__proto__ = User.options | |
// Private | |
function utilityMethod() { return "oh hai" } | |
// Public | |
this.say = function say() { | |
return this.options.awesome ? utilityMethod() : ':(' | |
} | |
} | |
// Default options | |
User.options = | |
{ awesome: false | |
, role: 'staff' | |
} | |
// Instance | |
var karbassi = new User({ awesome: true }) | |
karbassi.say() // "oh hai" |
SHUT YOUR FACE, YOU DIRTY PIRATE HOOKER
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're missing a semi-colon ;)