Skip to content
Related Articles

Related Articles

Improve Article

JQuery | isEmptyObject() method

  • Last Updated : 27 Apr, 2020

This isEmptyObject() Method in jQuery is used to determines if an object is empty.

Syntax:

jQuery.isEmptyObject( object )

Parameters: The isEmptyObject() method accepts only one parameter that is mentioned above and described below:

  • object : This parameter is the object that will be checked to see if it’s empty.

Return Value: It returns the boolean value.

Below examples illustrate the use of isEmptyObject() method in jQuery:



Example 1: In this example, the isEmptyObject() method checks an object to see if it’s empty.




<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | isEmptyObject() method</title
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </h1
      
    <h3>JQuery | isEmptyObject() method</h3>
    <b>Whether '{}' is a Empty Object : </b>
    <p></p>
      
    <script>
    $( "p" ).append( "" + $.isEmptyObject({}));
    </script>
</body>
</html>                                                                        

Output:

Example 2: In this example, the isEmptyObject() method also checks an object to see if it’s empty.




<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery | isEmptyObject() method</title
  
</head>
<body style="text-align:center;"
      
    <h1 style="color: green"
        GeeksForGeeks 
    </h1
      
    <h3>JQuery | isEmptyObject() method</h3>
    <b>Whether String is a Empty Object : </b>
    <p id ="gfg"></p>
    <b>Whether Array is a Empty Object : </b>
    <p id ="gfg1"></p>
      
    <script>
    // string ="Shubham"
    $( "#gfg" ).append( "Shubham : " + $.isEmptyObject("Shubham"));
      
    // array
    $( "#gfg1" ).append( 
"[1, 3, 4, 6, 8] : " + $.isEmptyObject([1, 3, 4, 6, 8]));
      
    </script>
</body>
</html>                                                                                                                    

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :