Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.isNumber() method is used to find whether the given value parameter is number or not. If the given value is a number then it returns True value otherwise, it returns False.
Syntax:
_.isNumber(value)
Parameters: This method accepts a single parameter as mentioned above and described below:
-
value: This parameter holds the value to check.
Return Value: This method returns true if the value is a number, else false.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Use of _.isNumber() method console.log(_.isNumber(10)); console.log(_.isNumber( 'neveropen' )); console.log(_.isNumber(15.675)); |
Output:
true false true
Example 2:
Javascript
// Requiring the lodash library const _ = require( "lodash" ); // Use of _.isNumber() // method console.log(_.isNumber( true )); console.log(_.isNumber(Number.MIN_VALUE)); console.log(_.isNumber(Infinity)); console.log(_.isNumber( '3' )); |
Output:
false true true false