The jQuery.makeArray() utility turns array-like objects into real JavaScript arrays. This tutorial covers syntax, five worked examples with NodeLists and jQuery collections, comparisons with toArray() and Array.from(), and when conversion unlocks native array methods.
01
Syntax
$.makeArray(obj)
02
NodeList
DOM collections
03
jQuery
$("li") → array
04
arguments
Function args
05
Plain array
True Array out
06
Re-wrap
Use $() again
Fundamentals
Introduction
Not everything that looks like an array is an array. DOM APIs return NodeLists; jQuery selections expose .length and [0] indexing but lack native methods like .reverse() and .map() (unless you use jQuery’s own helpers).
jQuery.makeArray() (also written $.makeArray()) bridges that gap: pass any array-like object, get back a genuine JavaScript Array you can use with ES5+ array methods or feed into utilities like $.merge() and $.grep().
Concept
Understanding the jQuery.makeArray() Method
jQuery.makeArray(obj) copies indexed values from obj into a new array from index 0 to obj.length - 1. The return value is always a plain array — special features of the source (jQuery methods, NodeList live binding in some browsers) are not carried over.
After conversion you can call any native array method. To get jQuery behavior back on DOM nodes, wrap the result: $( $.makeArray(nodeList) ).
💡
Beginner Tip
If arr.reverse is undefined, you probably have a NodeList or jQuery object — not a true array. Run $.makeArray(arr) first, then call .reverse().
Foundation
📝 Syntax
General form of jQuery.makeArray:
jQuery
jQuery.makeArray( obj )
// or
$.makeArray( obj )
Parameters
obj — any array-like object to convert: NodeList, HTMLCollection, jQuery collection, arguments, or a custom object with length and numeric keys.
Return value
A new true JavaScript Array containing the indexed values from obj.
Minimal workflow
jQuery
var nodeList = document.querySelectorAll("p");
var arr = $.makeArray(nodeList);
console.log(Array.isArray(arr)); // true
Cheat Sheet
⚡ Quick Reference
Goal
Code
NodeList to array
$.makeArray(document.querySelectorAll("div"))
jQuery to array
$.makeArray($("li"))
arguments to array
$.makeArray(arguments)
Re-wrap as jQuery
$($.makeArray(nodes))
Check result
Array.isArray(result) === true
jQuery-only alternative
$("li").toArray() on selections
Compare
📋 $.makeArray vs toArray() vs Array.from
Three ways to get a real array — different inputs and contexts.
$.makeArray
any array-like
Static utility; arguments, NodeList, $()
toArray()
jQuery only
Instance method on DOM selections
Array.from
native ES2015
No jQuery required
Spread
[...nodeList]
Modern shorthand for iterables
Hands-On
Examples Gallery
Each example uses $.makeArray(). Open DevTools or use the Try-it links to run them interactively.
📚 Getting Started
Convert DOM NodeLists and verify the result is a true array.
Example 1 — Convert a NodeList to an Array
querySelectorAll returns a NodeList — use $.makeArray() before native array methods.
jQuery
var nodeList = document.querySelectorAll("p");
var arr = $.makeArray(nodeList);
console.log(Array.isArray(nodeList)); // false
console.log(Array.isArray(arr)); // true
console.log(arr.length); // number of <p> elements
jQuery walks from index 0 to length - 1 and copies each reference into a new Array object. The NodeList itself is unchanged.
📈 Practical Patterns
jQuery collections, function arguments, DOM reordering, and native map.
Example 2 — Convert a jQuery Collection
Official API pattern — a jQuery object is array-like but not a true array.
jQuery
var $obj = $("li");
var arr = $.makeArray($obj);
console.log($obj.jquery !== undefined); // true — still a jQuery object
console.log(Array.isArray(arr)); // true — plain array of DOM nodes
The jQuery wrapper keeps its methods; the converted array holds raw DOM element references. For jQuery-only workflows, $("li").toArray() is equivalent.
Example 3 — Convert the arguments Object
Inside functions, arguments is array-like but not an array — classic use case for makeArray.
jQuery
function collect() {
var args = $.makeArray(arguments);
return args.join(", ");
}
console.log(collect("a", "b", "c")); // "a, b, c"
Once converted, you can pass args to .map(), spread it, or merge it with $.merge(). Modern code often uses rest parameters (...args) instead.
Example 4 — Reverse DOM Order (Official Demo Pattern)
Convert a NodeList, call .reverse(), then re-wrap with $() — from the jQuery API docs.
jQuery
// NodeList from getElementsByTagName — array-like, no .reverse()
var elems = document.getElementsByTagName("div");
var arr = $.makeArray(elems);
arr.reverse(); // native Array method now works
$(arr).appendTo("body"); // re-wrap and move nodes
You could use $.map() on the jQuery object instead, but makeArray + native .map() keeps logic in standard JavaScript when you only need element data.
Applications
🚀 Common Use Cases
DOM reordering — reverse or sort NodeLists before re-inserting elements.
Function arguments — convert arguments to a real array in pre-ES6 code.
Utility compatibility — feed NodeLists into $.merge() or $.grep() on older jQuery.
Native array methods — use .filter(), .slice(), or .reduce() on jQuery selections.
Interop with non-jQuery APIs — pass a true array to libraries that reject array-like objects.
Extract DOM nodes — get plain element references out of a jQuery wrapper.
🧠 How jQuery.makeArray() Converts Input
1
Read length
jQuery reads obj.length to know how many indexed slots to copy.
Inspect
2
Copy slots
Values at indexes 0 through length - 1 are pushed into a new Array.
Build
3
Drop extras
jQuery methods, NodeList prototypes, and other special features are not copied — only indexed values.
Plain
4
📦
Return array
A true JavaScript Array — Array.isArray returns true.
Important
📝 Notes
Available since jQuery 1.2.
The source object is not modified — a new array is allocated.
Shallow copy: array elements are references (DOM nodes, objects), not deep clones.
Objects with incorrect length (sparse or padded) may produce unexpected results — input should be genuinely array-like.
After conversion, wrap with $() to restore jQuery methods on DOM nodes.
On jQuery selections only, .toArray() is a convenient instance-method alternative.
Compatibility
Browser Support
jQuery.makeArray() has been part of jQuery since jQuery 1.2+. It works wherever jQuery runs — all modern browsers and legacy IE when paired with a supported jQuery build.
✓ jQuery 1.2+
jQuery jQuery.makeArray()
Supported in jQuery 1.x, 2.x, and 3.x. Behavior is consistent across browsers because jQuery owns the conversion logic.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
jQuery.makeArray()Universal
Bottom line: Safe in any project that already includes jQuery. Without jQuery, use Array.from(), spread syntax, or Array.prototype.slice.call().
Wrap Up
Conclusion
The jQuery.makeArray() utility turns array-like objects into real JavaScript arrays. Reach for it when NodeLists, jQuery collections, or arguments need native array methods or jQuery utilities that expect true arrays.
Remember: conversion produces a plain array — re-wrap with $() when you need jQuery behavior on the elements again, then explore jQuery.inArray() for searching those arrays.
Use $.makeArray() before native .reverse() or .sort() on NodeLists
Re-wrap with $() after array manipulation on DOM nodes
Use $("sel").toArray() when you already have a jQuery selection
Verify with Array.isArray() when debugging type issues
Prefer rest parameters over arguments in new JavaScript code
❌ Don’t
Assume jQuery objects support all Array prototype methods
Expect jQuery methods to survive on the converted array
Pass plain objects without length — they are not array-like
Deep-clone DOM trees via makeArray — it copies references only
Confuse makeArray with merge or extend
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about jQuery.makeArray()
Convert array-like data the jQuery way.
5
Core concepts
🔄01
$.makeArray
To true Array
API
📄02
NodeList
DOM collections
Input
📑03
Plain out
No jQuery methods
Output
↻04
Re-wrap
$() again
Pattern
⚠05
vs toArray
Any array-like
Compare
❓ Frequently Asked Questions
jQuery.makeArray(obj) converts an array-like object into a true JavaScript Array. It returns a plain array you can pass to native methods like .reverse(), .map(), and .filter(), or to jQuery utilities such as $.merge() and $.grep().
Any object with a numeric length and indexed values — NodeLists, HTMLCollections, the arguments object, jQuery collections, and custom { 0: 'a', 1: 'b', length: 2 } objects. Plain objects without length are not array-like.
makeArray() is a static utility that accepts any array-like input. toArray() is an instance method on a jQuery DOM collection only. Both produce a plain JavaScript array of DOM nodes when starting from a jQuery selection.
No. After conversion the result is a plain array. jQuery-specific methods on the original jQuery object are gone — wrap again with $() if you need jQuery methods on the elements.
Both convert array-like objects to arrays. Array.from() is native ES2015+. jQuery.makeArray() has been available since jQuery 1.2 and is the standard choice in jQuery codebases, especially for arguments and legacy browser support with jQuery loaded.
Use $.makeArray() when you already depend on jQuery, need to convert the arguments object, or want one consistent utility across NodeLists and jQuery objects. Modern code may use [...nodeList] or Array.from() when jQuery is not required.
Did you know?
The official jQuery demo for makeArray converts a NodeList of <div> elements, calls .reverse() on the resulting array, then uses $(arr).appendTo(document.body) to reorder them in the DOM. That single pattern shows why the utility exists — array-like is not array enough for native methods.