Example 1 — Iterate an Array
Log each index and value from a simple array.
$.each([52, 97], function (index, value) {
console.log(index + ": " + value);
});
// → 0: 52
// → 1: 97 
jQuery Utilities are standalone functions on the jQuery / $ namespace — not tied to a DOM selection. Key helpers include jQuery.each() for iteration, jQuery.map() for transforming collections, jQuery.grep() for filtering arrays, jQuery.extend() for merging objects, jQuery.merge() for combining arrays, jQuery.makeArray() for converting NodeLists into true arrays, jQuery.inArray() for finding a value’s index, jQuery.type() for accurate type detection, jQuery.isArray() for boolean array tests, jQuery.isEmptyObject() for empty object checks, jQuery.isFunction() for callback validation, jQuery.isNumeric() for finite number checks, jQuery.isPlainObject() for plain {} validation, jQuery.isWindow() for browser window detection, jQuery.isXMLDoc() for XML document checks, jQuery.contains() for DOM descendant tests, jQuery.data() for element data storage, jQuery.globalEval() for global script execution, and jQuery.noop() for optional callback placeholders. This hub links to 35 utility tutorials with full examples and try-it labs.
Generic iterator
Index + value
Key + value
Return false
Utility vs DOM
Same collection
Most jQuery tutorials focus on selecting DOM elements with $() and chaining methods. Utilities live one level up: they are global jQuery functions you call as jQuery.each(...) or $.each(...) without building a jQuery object first.
The most important utility for beginners is jQuery.each(). It gives you one consistent way to loop over arrays (numeric indexes), array-like objects (such as arguments or a NodeList), and plain JavaScript objects (named keys). That saves you from writing separate for loops for every data shape.
jQuery.each() vs $(...).each()These names look alike but target different collections:
Search by method name or browse by category. Each tutorial includes syntax, five try-it examples, and FAQs.
Walk collections with jQuery utility helpers.
| Method | Description | Tutorial |
|---|---|---|
jQuery.each() | Iterate over arrays, array-like objects, and plain objects with a generic callback. | Open |
jQuery.map() | Translate arrays and objects into a new array of transformed values with optional filter and flatten. | Open |
Select array elements that satisfy a boolean test function.
| Method | Description | Tutorial |
|---|---|---|
jQuery.grep() | Find array elements that pass a filter function; optional invert flag keeps non-matching items. | Open |
Merge and copy plain object properties with jQuery utility helpers.
| Method | Description | Tutorial |
|---|---|---|
jQuery.extend() | Merge properties from one or more objects into a target — shallow, deep recursive, or jQuery namespace. | Open |
Combine and copy array-like collections with jQuery utility helpers.
| Method | Description | Tutorial |
|---|---|---|
jQuery.merge() | Append elements from a second array-like object onto the first — preserves order, keeps duplicates. | Open |
jQuery.makeArray() | Convert NodeLists, jQuery collections, or arguments into a true JavaScript array. | Open |
jQuery.inArray() | Search an array for a value and return its index, or -1 when not found. | Open |
jQuery.uniqueSort() | Remove duplicate DOM node references and sort elements into document order. | Open |
jQuery.unique() | Legacy name for uniqueSort — deprecated since jQuery 3.0, alias with identical behavior for reading older code. | Open |
Inspect JavaScript values with jQuery type helpers.
| Method | Description | Tutorial |
|---|---|---|
jQuery.type() | Return an accurate lowercase type string for null, arrays, dates, regexps, and more. | Open |
jQuery.isArray() | Return true when a value is a genuine JavaScript array — not merely array-like. | Open |
jQuery.isEmptyObject() | Return true when an object has no enumerable properties. | Open |
jQuery.isFunction() | Return true when a value is a JavaScript function — validate callbacks safely. | Open |
jQuery.isNumeric() | Return true for finite numbers and numeric strings — reject NaN, Infinity, and units. | Open |
jQuery.isPlainObject() | Return true for plain {} objects safe to merge with jQuery.extend — not arrays or DOM nodes. | Open |
jQuery.isWindow() | Return true when a value is a browser window — global window or iframe contentWindow (deprecated in 3.3). | Open |
jQuery.isXMLDoc() | Return true when a DOM node is or belongs to an XML document — false for normal HTML pages. | Open |
Test DOM relationships and document context with jQuery helpers.
| Method | Description | Tutorial |
|---|---|---|
jQuery.contains() | Return true when a DOM element is a descendant of another — direct child or nested deeper. | Open |
jQuery.data() | Attach and retrieve arbitrary JavaScript data on DOM elements — safe internal cache with cleanup. | Open |
jQuery.removeData() | Delete one key or clear all jQuery data on a raw DOM element — low-level twin of .removeData(); prefer the instance method day to day. | Open |
jQuery.parseHTML() | Parse an HTML string into an array of DOM nodes — scripts excluded by default for safer parsing. | Open |
jQuery.parseXML() | Parse a well-formed XML string into an XMLDocument — wrap with jQuery for find() and text() on RSS and SOAP data. | Open |
jQuery.globalEval() | Execute JavaScript strings in the global scope — used for dynamic scripts; never pass untrusted input. | Open |
Low-level queue helpers — prefer .queue() / .dequeue() on elements for everyday animation chains.
| Method | Description | Tutorial |
|---|---|---|
jQuery.queue() | Show, add, or replace the function queue on a DOM element — low-level twin of .queue(); prefer the instance method day to day. | Open |
jQuery.dequeue() | Execute the next function on an element’s fx or custom queue — low-level twin of .dequeue(); prefer the instance method day to day. | Open |
Escape special characters when building CSS selector strings dynamically.
| Method | Description | Tutorial |
|---|---|---|
jQuery.escapeSelector() | Escape special characters in CSS selector strings — safe dynamic class and ID lookups since jQuery 3.0. | Open |
Deprecated internal flags — read for legacy code only; prefer Modernizr or native feature tests.
| Method | Description | Tutorial |
|---|---|---|
jQuery.support | Internal browser capability flags — deprecated for external use since 1.9, lazy function tests since 1.11; prefer Modernizr or native feature detection. | Open |
jQuery.browser | Removed user-agent flags msie mozilla webkit opera and version string — deprecated 1.3, removed 1.9, use feature detection or jQuery Migrate for legacy code. | Open |
Small utility functions that simplify common jQuery patterns.
| Method | Description | Tutorial |
|---|---|---|
jQuery.trim() | Remove leading and trailing whitespace from a string — deprecated; prefer native String.prototype.trim(). | Open |
jQuery.now() | Return the current time in milliseconds since the Unix epoch — alias for Date.now(); deprecated in jQuery 3.3. | Open |
jQuery.parseJSON() | Parse a well-formed JSON string into a JavaScript object, array, or primitive — prefer JSON.parse(). | Open |
jQuery.proxy() | Return a function with a fixed this context — ideal for event handlers; prefer Function.prototype.bind(). | Open |
jQuery.noop() | Return a shared empty function — default placeholder for optional callbacks in plugins. | Open |
Additional jQuery utility methods — search or browse alphabetically.
| Method | Description | Tutorial |
|---|---|---|
jquery-error() | Tutorial for the jQuery utility jquery error method. | Open |
jquery-sub() | Tutorial for the jQuery utility jquery sub method. | Open |
Include jQuery 3.7+ and open DevTools Console (F12) to run each snippet, or open the full jQuery.each() tutorial for try-it labs.
Log each index and value from a simple array.
$.each([52, 97], function (index, value) {
console.log(index + ": " + value);
});
// → 0: 52
// → 1: 97 Walk enumerable keys on a plain object.
const obj = { flammable: "inflammable", duh: "no duh" };
$.each(obj, function (key, value) {
console.log(key + ": " + value);
});
// → flammable: inflammable
// → duh: no duh return falseStop iterating when a condition is met.
$.each(["a", "b", "c", "d"], function (i, letter) {
console.log(letter);
if (letter === "c") {
return false; // stops — like break
}
});
// → a, b, c (d is never logged) Use side effects inside the callback to accumulate a total.
const prices = [9.99, 14.50, 3.25];
let total = 0;
$.each(prices, function (i, price) {
total += price;
});
console.log("Total:", total.toFixed(2)); // → Total: 27.74 Combine array and object iteration to update DOM elements — adapted from the jQuery API docs.
const words = ["one", "two", "three", "four", "five"];
const numerals = { one: 1, two: 2, three: 3, four: 4, five: 5 };
$.each(words, function (i, word) {
$("#" + word).text("Mine is " + word + ".");
return word !== "three"; // stop after "three"
});
$.each(numerals, function (key, num) {
$("#" + key).append(" — " + num);
}); Full syntax, five try-it labs, comparisons, and best practices.
6 people found this page helpful