Open In App

JQuery | isArray() method

Last Updated : 27 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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=
</script>
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </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
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </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:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads