Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Created January 12, 2012 17:17
Show Gist options
  • Save jmaicher/1601830 to your computer and use it in GitHub Desktop.
Save jmaicher/1601830 to your computer and use it in GitHub Desktop.
How Backbone.js Implements Inheritance
// 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