jQuery isEmptyObject() example

jQuery isEmptyObject() function is used to check to see if an object is empty (contains no enumerable properties).

Syntax

jQuery.isEmptyObject( object )
object - The object that will be checked to see if it's empty.

Example

Check an object to see if it's empty.
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>jQuery.isEmptyObject demo</title>
    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
</head>

<body>
    <script>
        jQuery.isEmptyObject({}); // true
        jQuery.isEmptyObject({
            foo: "bar"
        }); // false
    </script>

</body>

</html>
Try it Yourself - Copy paste code in Online HTML Editor to see the result

References


Comments