Skip to content
Related Articles

Related Articles

Improve Article

Underscore.js | _.isNumber() Function

  • Last Updated : 27 Apr, 2020

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

Syntax:

_.isNumber( object )

Parameters: This function accepts one parameter as mentioned above and described below:

  • object: This parameter holds the object element that need to be check whether it is number or not.

Return Value: It returns True if the given object is number, False otherwise.

Example 1:






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

Output:

Example 2:




<!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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :