Open In App

Underscore.js _.isString() Function

Last Updated : 01 Aug, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report
The _.isString() function is used to check whether the given object element is string or not. Syntax:
_.isString( object )
Parameters: This function accepts single parameter as mentioned above and described below:
  • object: It contains the value of object that need to be check whether it is an string or not.
Return Value: It returns a Boolean value True if given object element is string, False otherwise. Example 1: 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">

        var info = {
            Company: 'GeeksforGeeks',
            Address: 'Noida',
            Contact: '+91 9876543210'
        };
        console.log(_.isString(info));

        var str = 'GeeksforGeeks';
        console.log(_.isString(str));
    </script>
</body>

</html>
Output: Example 2: 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(_.isString(true));
        console.log(_.isString(10));
        console.log(_.isString('GeeksforGeeks'));
        console.log(_.isString("20"));
    </script>
</body>

</html>
Output:

Next Article

Similar Reads