Created
May 4, 2014 03:04
-
-
Save anonymous/da20acbe0f0cc59afad7 to your computer and use it in GitHub Desktop.
Javascript Object Creation Patterns
This file contains 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
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