In this lesson we surveyed the features that jQuery provides outside of the methods that operate on a jQuery object. These included an assortment of functions, as well as a set of flags, defined directly on the jQuery top-level name (as well as its $ alias).
First, you learned about the flags that deal with animations. Setting $.fx.off lets you completely disable animations on your website so that changes will happen immediately. Then we introduced $.fx.interval, a flag to change the smoothness with which animations run.
Recognizing that page authors may sometimes wish to use other libraries in conjunction with jQuery, jQuery provides $.noConflict(), which allows other libraries to use the $ alias. After calling this function, all jQuery operations must use the jQuery name rather than $.
jQuery also provides a set of functions that are useful for dealing with data sets in arrays. $.each() makes it easy to traverse through items in collections; $.grep() allows you to create new arrays by filtering the data using whatever filtering criteria you’d like to use; $.map() allows you to easily apply your own transformations to a source to produce a corresponding new array with the transformed values.
You can also use jQuery to test if a value is in an array with $.inArray() and even test if a value is an array itself with $.isArray(). You can also test for functions using $.isFunction() or check the type of an object using the $.type() utility.
Another set of functions that the library offers allows you to deal with different formats. Two of them, $.parseJSON() and $.parseXML(), parse the two best known formats used on the web to exchange information: JSON and XML. The remaining one, $.parseHTML(), lets you parse HTML markup.
In addition to a bunch of minor functions, you also discovered how to merge objects using jQuery’s $.extend() function. This function allows you to merge the properties of any number of source objects into a target object. Finally, the $.proxy() function lets you change the function context of any function in your code.
With these additional tools safely tucked away in your toolbox, you’re ready to tackle the utility functions that jQuery provides to perform Ajax requests.
Leave a Reply