Open In App

Underscore.js _.isNumber() Function

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
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=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">
    </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= 
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"> 
    </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:


Similar Reads