Skip to content

Instantly share code, notes, and snippets.

@gf3
Created April 25, 2011 21:12
Show Gist options
  • Save gf3/941238 to your computer and use it in GitHub Desktop.
Save gf3/941238 to your computer and use it in GitHub Desktop.
An Example Class
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"
@rwaldron
Copy link

You're missing a semi-colon ;)

@gf3
Copy link
Author

gf3 commented Apr 25, 2011

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