Created
April 28, 2013 16:31
-
-
Save colinmegill/5477422 to your computer and use it in GitHub Desktop.
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
/* 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