Open In App

Underscore.js _.isObject() Function

Last Updated : 25 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Underscore.js_.isObject() function is used to check whether the given object is an object or not. It returns a Boolean value True if the given object element is an object and returns False otherwise. JavaScript functions and arrays are objects, while the strings and numbers are not objects.

Syntax:

_.isObject( value );

Parameters:

  • object: This parameter holds the value of the object that needs to be checked whether it is an object or not.

Return Value:

It returns True if the given object element is an object and False otherwise.

Example 1: This example shows the use of the underscore.js _.isObject() function.

html
<!DOCTYPE html>
<html>

<head>
    <script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">
    </script>
</head>

<body>
    <script type="text/javascript">

        let info = {
            Company: { name: 'GeeksforGeeks' },
            Contact: {
                Address: {
                    AddressInfo: 'Noida',
                    ContNo: '+91 9876543210'
                }
            }
        };

        console.log(_.isObject(info)); 
    </script>
</body>

</html>

Output:

Example 2: This example shows the use of the underscore.js _.isObject() function.

html
<!DOCTYPE html>
<html>

<head>
    <script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">
    </script>
</head>

<body>
    <script type="text/javascript">

        console.log(_.isObject(true));
        console.log(_.isObject(1));
        console.log(_.isObject('GeeksforGeeks'));
        console.log(_.isObject([1, 2, 3])); 
    </script>
</body>

</html>

Output:


Next Article

Similar Reads