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 = 'neveropen'; Â Â Â Â Â Â Â Â 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('neveropen')); Â Â Â Â Â Â Â Â console.log(_.isNumber(15.675)); Â Â Â Â </ script > </ body > Â Â </ html > |
Output: