Underscore.js _.isNumber() Function
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 = 'w3wiki'; 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('w3wiki')); console.log(_.isNumber(15.675)); </ script > </ body > </ html > |
Output:
Contact Us