Lodash _.isInteger() method checks whether the given value is an Integer or not and returns the corresponding boolean value.
Syntax:
_.isInteger(value);Parameters:
- value: This parameter holds the value that needs to be checked for an Integer.
Return Value:
- This method returns a Boolean value(Returns true if the given value is an Integer, else false).
Example 1: In this example, we are getting true as the lodash _isInteger() method is returning true because 100 is an integer value.
// Defining Lodash variable
const _ = require('lodash');
// Checking for Integer
console.log("The Value is Integer : "
+ _.isInteger(100));
Output:
The Value is Integer : trueExample 2: In this example, we are getting false as the lodash _isInteger() method is returning false because the given value is a string, not an integer.
// Defining Lodash variable
const _ = require('lodash');
// Checking for Integer
console.log("The Value is Integer : "
+ _.isInteger("10"));
Output:
The Value is Integer : falseExample 3: In this example, we are getting false as the lodash _isInteger() method is returning false because the given value is Infinity, not an integer.
// Defining Lodash variable
const _ = require('lodash');
// Checking for Integer
console.log("The Value is Integer : "
+ _.isInteger(Infinity));
Output:
The Value is Integer : false