Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Backbone models contain data for an application as well as the logic
around this data. For example, we can use a model to represent the concept
of a todo item, including its attributes like title
(todo content) and completed (current state of the
todo).
We can create models by extending Backbone.Model as follows:
varTodo=Backbone.Model.extend({});// We can then create our own concrete instance of a (Todo) model// with no values at all:vartodo1=newTodo();// Following logs: {}console.log(JSON.stringify(todo1));// or with some arbitrary data:vartodo2=newTodo({title:'Check the attributes of both model instances in the console.',completed:true});// Following logs: {"title":"Check the attributes of both model