JQuery | isEmptyObject() method

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                                                                        

chevron_right


Output:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>                                                                                                                    

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.