Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (42 sloc) 1.868 kB
<?xml version="1.0"?>
<entry type="method" name="jQuery.makeArray" return="Array">
<argument name="obj" type="PlainObject">
<desc>Any object to turn into a native Array.</desc>
<desc>Convert an array-like object into a true JavaScript array.</desc>
<p>Many methods, both in jQuery and in JavaScript in general, return objects that are array-like. For example, the jQuery factory function <code>$()</code> returns a jQuery object that has many of the properties of an array (a length, the <code>[]</code> array access operator, etc.), but is not exactly the same as an array and lacks some of an array's built-in methods (such as <code>.pop()</code> and <code>.reverse()</code>).</p>
<p>Note that after the conversion, any special features the object had (such as the jQuery methods in our example) will no longer be present. The object is now a plain array.</p>
<desc>Turn a collection of HTMLElements into an Array of them.</desc>
var elems = document.getElementsByTagName("div"); // returns a nodeList
var arr = jQuery.makeArray(elems);
arr.reverse(); // use an Array method on list of dom elements
div { color:red; }
<desc>Turn a jQuery object into an array</desc>
var obj = $('li');
var arr = $.makeArray(obj);
<results><![CDATA[(typeof obj === 'object' && obj.jquery) === true;
jQuery.isArray(arr) === true;]]></results>
<category slug="utilities"/>
<category slug="version/1.2"/>
Jump to Line
Something went wrong with that request. Please try again.