Skip to content

Instantly share code, notes, and snippets.

@gf3
Created April 25, 2011 21:12
Show Gist options
  • Select an option

  • Save gf3/941238 to your computer and use it in GitHub Desktop.

Select an option

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"
@gf3

gf3 commented Apr 25, 2011

Copy link
Copy Markdown
Author

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