Easy Tutorial
❮ Event Dblclick Jq Event Type ❯

jQuery.makeArray() Method

jQuery Miscellaneous Methods

Example

Convert a collection of HTML elements into an array

$(function () { 
    var elems = document.getElementsByTagName("div"); // Returns a node list
    var arr = jQuery.makeArray(elems);
    arr.reverse(); // Use an array method on the list
    $(arr).appendTo(document.body);
})

Definition and Usage

The $.makeArray() function is used to convert an array-like object into a true array object.

Note: Array-like objects have many properties of arrays (such as the length property, [] array access operator, etc.), but they are not arrays and lack the built-in methods inherited from the array prototype object (such as pop(), reverse(), etc.).


Syntax

Parameter Description
object Object type The array-like object to be converted into an array.

More Examples

Convert to Array

jQuery Miscellaneous Methods

❮ Event Dblclick Jq Event Type ❯