Chapter 9. Beyond the DOM with jQuery utility functions

 

This chapter covers

  • The jQuery properties
  • Avoiding conflict between jQuery and other libraries
  • Array manipulation functions
  • Extending and merging objects
  • Parsing different formats
  • Dynamically loading new scripts

Up to this point, we’ve spent a number of chapters examining the jQuery methods that operate upon a set of DOM elements selected by using the $() function. But you may recall that way back in chapter 1 we also introduced the concept of utility functions—functions namespaced by jQuery/$ that don’t operate on a jQuery object. These functions could be thought of as top-level functions except that they’re defined on the $ instance rather than window, keeping them out of the global scope. Generally, these functions either operate upon JavaScript objects other than DOM elements or perform some non-object-related operation (such as an Ajax request or the parsing of a XML string).

In addition to functions, jQuery provides some properties (sometimes referred to as flags) that are defined within the jQuery/$ namespace. Some of these properties are meant for internal use only, but because they’re documented in the jQuery API website and some plugins use them, we thought that they’re worth a mention for the most curious among you.

You may wonder why we waited until this chapter to introduce these functions and properties. We had two reasons:

9.1. Using the jQuery properties

9.2. Using other libraries with jQuery

9.3. Manipulating JavaScript objects and collections

9.4. Miscellaneous utility functions

9.5. Summary