I want to define which properties a class has. We use backbone for OOP. I've read that backbone model gets its properties when initialized, and only methods are defined for the class using extend
. But I think that having explicitly defined class fields adds to readability. Is there some convention on how to do that?
From the fine manual:
extend
Backbone.Model.extend(properties, [classProperties])
[...] as well as optional classProperties to be attached directly to the constructor function.
Similarly for collections, routers, and views.
To define a class method on a model:
var M = Backbone.Model.extend({
// instances methods and properties go here...
}, {
some_class_method: function() { ... }
});
M.some_class_method(); // Then this will work.