Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2014 03:04
Show Gist options
  • Save anonymous/da20acbe0f0cc59afad7 to your computer and use it in GitHub Desktop.
Save anonymous/da20acbe0f0cc59afad7 to your computer and use it in GitHub Desktop.
Javascript Object Creation Patterns
From "Beginning Backbone.js":
function Message(subject, recipient, content) {
this.subject = subject;
this.recipient = recipient;
this.content = content;
}
Message.prototype.show = function(){
console.log('To:' + this.recipient + 'Subject: ' + this.subject + 'Message:' + this.content);
};
var myEmail = new Message('Javascript is cool', 'you@gmail.com', 'Prototype is useful');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment