Open In App

Underscore.js _.isNumber() Function

Last Updated : 10 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Underscore.js _.isNumber() function is used to check whether the given object parameter is a number or not. If the given object is a number then it returns True value otherwise, it returns False.

Syntax:

_.isNumber( object );

Parameters:

  • object: This parameter holds the object element that needs to be checked whether it is a number or not.

Return Value:

It returns True if the given object is a number, and False otherwise.

Example 1: This example shows the use of the Underscore.js _.isNumber() Function.

html




<!DOCTYPE html>
<html>
 
<head>
    <script type="text/javascript" src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        console.log(_.isNumber(arr));
 
 
        let fun = function (element) {
            return element % 2 != 0;
        };
        console.log(_.isNumber(fun));
 
        let str = 'GeeksforGeeks';
        console.log(_.isNumber(str.length));
    </script>
</body>
 
</html>


Output:

Example 2: This example shows the use of the Underscore.js _.isNumber() Function.

html




<!DOCTYPE html>
<html>
 
<head>
    <script type="text/javascript" src=
    </script>
</head>
 
<body>
    <script type="text/javascript">
 
        console.log(_.isNumber(true));
        console.log(_.isNumber(10));
        console.log(_.isNumber('GeeksforGeeks'));
        console.log(_.isNumber(15.675));
    </script>
</body>
 
</html>


Output:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads