In addition to jQuery, Backbone also requires one library called
Underscore. Underscore was written by Jeremy Ashkenas (the creator of Backbone), and many of its functions are relevant to the topics we've discussed so far. Because Underscore is required by Backbone, you'll already have it available to you if you use Backbone. All of these functions can be accessed via the _
character (similar to how jQuery functions are accessed via the $
character).
As we discussed the call
and apply
methods, you may have realized that this is more fluid in JavaScript than in other languages. While a function that is called normally will preserve the this
method automatically, when a function is called in an unusual way—such as through window.setTimeout
or as a callback to a jQuery event handler or AJAX call—that won't be the case. The window.setTimeout
will change this to the global window object, while jQuery event callbacks will change this
to the element that triggered the event...