In http://addyosmani.github.com/backbone-fundamentals/, it is said that
every single one of the following objects inherits from Backbone.Events:
Backbone.Model
Backbone.Collection
Backbone.Router
Backbone.History
Backbone.View
and I can also find in backbone.js the following:
// Attach all inheritable methods to the Model prototype.
_.extend(Model.prototype, Events, { ....
However, I tried to check for the inheritance, by
Backbone.Model.prototype.__proto__ === Backbone.Events
in Firebug, and it shows false, and
Backbone.Model.prototype.__proto__.__proto__
is already null, meaning the end of the prototype chain. So how can the inheritance be shown?
The page you’re referencing is incorrect, nothing in Backbone inherits from
Backbone.Events. However,Backbone.Eventsis mixed into the other Backbone “classes”. The bit of code you mention:is not setting up inheritance, it is simply mixing
EventsintoModel‘s prototype and the effect is similar to this:so it is simply add
Events‘s methods toModel. The Backbone document only says this:Note the mixed in terminology.
Backbone.Eventsisn’t even a constructor function (it is simply an object) so there’s nothing to inherit from.