jQuery.isArray()
** DEPRECATED **S2C Home « Utilities « jQuery.isArray()
Array object detection.
Description
The jQuery.isArray()
jQuery Type utility method, returns a boolean dependant upon the specified object being a JavaScript Array
object.
Shorthand version $.isArray()
- Only returns
true
forArray
objects, not array-like objects. Objects that are array-like in nature have characteristics similar to an array.- Generally with array-like objects you can use the array access operator
[]
and the length property for example. - You do not get full access to the methods of a true
Array
object.
- Generally with array-like objects you can use the array access operator
This method was deprecated in jQuery 3.2.
Syntax
Signature | Description |
---|---|
jQuery.isArray( object ) | Return a boolean dependant upon the specified object being a JavaScript Array object. |
Parameters
Parameter | Description | Type |
---|---|---|
object | The object to test to see if it is an Array object. | Object |
Return
A Boolean
object.
jQuery.isArray( object )
ExampleTop
Return a boolean dependant upon the specified object being a JavaScript Array
object.
In the example below when we press the button we create some variables and test to see if they are Array
objects.
$(function(){
$('#btn1').one('click', function(){
var obj1 = 'A string', obj2 = [], obj3 = {}, obj4 = new Object;
$('#div1').append('Is obj1 an Array
object? ' + $.isArray( obj1 ) + '<br>');
$('#div1').append('Is obj2 an Array
object? ' + $.isArray( obj2 ) + '<br>');
$('#div1').append('Is obj3 an Array
object? ' + $.isArray( obj3 ) + '<br>');
$('#div1').append('Is obj4 an Array
object? ' + $.isArray( obj4 ) + '<br>');
});
});
div1. Some initial text.