jQuery Utilities

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 35 Tutorials
Utility functions

What You’ll Learn

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.

01

$.each()

Generic iterator

02

Arrays

Index + value

03

Objects

Key + value

04

Break

Return false

05

vs .each()

Utility vs DOM

06

Return

Same collection

Introduction

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:

jQuery.each(arr, fn) → any array, object, or array-like data $("li").each(fn) → only elements inside a jQuery DOM collection Array.forEach(fn) → native arrays only; cannot break with return false

Utilities Method Tutorial Index

Search by method name or browse by category. Each tutorial includes syntax, five try-it examples, and FAQs.

Iteration

2 tutorials

Walk collections with jQuery utility helpers.

MethodDescriptionTutorial
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

Filter

1 tutorial

Select array elements that satisfy a boolean test function.

MethodDescriptionTutorial
jQuery.grep()Find array elements that pass a filter function; optional invert flag keeps non-matching items.Open

Objects

1 tutorial

Merge and copy plain object properties with jQuery utility helpers.

MethodDescriptionTutorial
jQuery.extend()Merge properties from one or more objects into a target — shallow, deep recursive, or jQuery namespace.Open

Arrays

5 tutorials

Combine and copy array-like collections with jQuery utility helpers.

MethodDescriptionTutorial
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

Type Checking

8 tutorials

Inspect JavaScript values with jQuery type helpers.

MethodDescriptionTutorial
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

DOM

6 tutorials

Test DOM relationships and document context with jQuery helpers.

MethodDescriptionTutorial
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

Queues

2 tutorials

Low-level queue helpers — prefer .queue() / .dequeue() on elements for everyday animation chains.

MethodDescriptionTutorial
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

Selectors

1 tutorial

Escape special characters when building CSS selector strings dynamically.

MethodDescriptionTutorial
jQuery.escapeSelector()Escape special characters in CSS selector strings — safe dynamic class and ID lookups since jQuery 3.0.Open

Browser Detection

2 tutorials

Deprecated internal flags — read for legacy code only; prefer Modernizr or native feature tests.

MethodDescriptionTutorial
jQuery.supportInternal browser capability flags — deprecated for external use since 1.9, lazy function tests since 1.11; prefer Modernizr or native feature detection.Open
jQuery.browserRemoved 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

Helpers

5 tutorials

Small utility functions that simplify common jQuery patterns.

MethodDescriptionTutorial
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

More Utilities

2 tutorials

Additional jQuery utility methods — search or browse alphabetically.

MethodDescriptionTutorial
jquery-error()Tutorial for the jQuery utility jquery error method.Open
jquery-sub()Tutorial for the jQuery utility jquery sub method.Open

Examples Gallery

Include jQuery 3.7+ and open DevTools Console (F12) to run each snippet, or open the full jQuery.each() tutorial for try-it labs.

Example 1 — Iterate an Array

Log each index and value from a simple array.

jQuery
$.each([52, 97], function (index, value) {
  console.log(index + ": " + value);
});
// → 0: 52
// → 1: 97
Try It Yourself

Example 2 — Iterate Object Properties

Walk enumerable keys on a plain object.

jQuery
const obj = { flammable: "inflammable", duh: "no duh" };

$.each(obj, function (key, value) {
  console.log(key + ": " + value);
});
// → flammable: inflammable
// → duh: no duh
Try It Yourself

Example 3 — Break the Loop with return false

Stop iterating when a condition is met.

jQuery
$.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)
Try It Yourself

Example 4 — Sum Array Values

Use side effects inside the callback to accumulate a total.

jQuery
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
Try It Yourself

Example 5 — Words and Numerals (Official Demo Style)

Combine array and object iteration to update DOM elements — adapted from the jQuery API docs.

jQuery
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);
});

❓ Frequently Asked Questions

Utilities are standalone jQuery functions — not methods on a DOM selection — that help with common tasks like iterating collections. jQuery.each() is the classic utility for walking arrays and objects with one consistent callback signature.
jQuery.each(collection, fn) is a static utility that works on any array or object. $(selector).each(fn) only iterates over elements in a jQuery DOM collection. They look similar but serve different purposes.
Return false from the callback function. That breaks out of the loop immediately — similar to break in a for loop. Returning any other value continues to the next item.
No. The iterator walks the collection; your callback may mutate elements, but $.each itself does not change the structure of the array or object.
It returns the first argument — the same collection reference you passed in. That makes it easy to chain or reuse the original data after iteration.
Read the overview, try the five examples, then open the jQuery.each() tutorial for syntax, try-it labs, and a full comparison with native Array.forEach and DOM .each().

Continue to jQuery.each()

Full syntax, five try-it labs, comparisons, and best practices.

jQuery.each() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful