JQuery | isArray() method
This isArray() Method in jQuery is used to determines whether the argument is an array.
Syntax:
jQuery.isArray( object )
Parameters: The isArray() method accepts only one parameter that is mentioned above and described below:
- object : This parameter is the object to test whether or not it is an array.
Return Value: It returns the boolean value.
Below examples illustrate the use of isArray() method in jQuery:
Example 1: In this example, the isArray() method checks the parameter is an array.
<!DOCTYPE html> < html > < head > < meta charset = "utf-8" > < title >JQuery | isArray() method</ title > < script src = "https://code.jquery.com/jquery-3.4.1.js" > </ script > </ head > < body style = "text-align:center;" > < h1 style = "color: green" > w3wiki </ h1 > < h3 >JQuery | isArray() method</ h3 > < b >Whether "{}" is a Array Object : </ b > < p ></ p > < script > $( "p" ).append( "" + $.isArray("{}")); </ script > </ body > </ html > |
Output:
Example 2: In this example, the isArray() method also checks the parameter is an array.
<!DOCTYPE html> < html > < head > < meta charset = "utf-8" > < title >JQuery | isArray() method</ title > < script src = "https://code.jquery.com/jquery-3.4.1.js" ></ script > </ head > < body style = "text-align:center;" > < h1 style = "color: green" > w3wiki </ h1 > < h3 >JQuery | isArray() method</ h3 > < b >Whether String is a Array Object : </ b > < p id = "gfg" ></ p > < b >Whether Array is a Array Object : </ b > < p id = "gfg1" ></ p > < script > // string ="Shubham" $( "#gfg" ).append( "Shubham : " + $.isArray("Shubham")); // array $( "#gfg1" ).append( "[1, 3, 4, 6, 8] : " + $.isArray([1, 3, 4, 6, 8])); </ script > </ body > </ html > |
Output:
Contact Us