Created
January 12, 2012 17:17
-
-
Save jmaicher/1601830 to your computer and use it in GitHub Desktop.
How Backbone.js Implements Inheritance
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
// create a constructor which inherits from Backbone.Model | |
var ToDo = Backbone.Model.extend( | |
// instance properties | |
{ | |
toJSON: function() { ... } | |
}, | |
// static properties | |
{ | |
createFromJSON: function(jsonObj) { ... } | |
} | |
); | |
// create instance and invoke instance method | |
var item = new ToDo(); | |
item.toJSON(); | |
// invoke static method | |
ToDo.createFromJSON(...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment