Skip to content

Instantly share code, notes, and snippets.

@colinmegill
Created April 28, 2013 16:31
Show Gist options
  • Save colinmegill/5477422 to your computer and use it in GitHub Desktop.
Save colinmegill/5477422 to your computer and use it in GitHub Desktop.
/* The capitalized 'Note' defines the data structure that every lowercase 'note' instance will inherit from */
/* 'initialize' is called when you create a new instance of the class using the 'new' keyword */
/* when you initialize a new instance of the class, each property of the default object becomes a property of the instance */
var Note = Backbone.Model.extend({
initialize: function() { ... },
methodOne: function() {...}
defaults: {
propertyOne: "",
propertyTwo: ""
}
});
/* firstNote will inherit not only the properties and methods we define in our Note class above, but also every property and method of Backbone.Model */
var firstNote = new Note({
propertyOne: "A property value unique to this instance"
/* since propertyTwo is not being passed in on initalize, it will have the default value of empty string */
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment