Open In App

Lodash _.isInteger() Method

Last Updated : 04 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

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.

JavaScript
// Defining Lodash variable 
const _ = require('lodash');

// Checking for Integer
console.log("The Value is Integer : "
    + _.isInteger(100));

Output:

The Value is Integer : true

Example 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.

JavaScript
// Defining Lodash variable 
const _ = require('lodash');

// Checking for Integer
console.log("The Value is Integer : "
    + _.isInteger("10"));

Output:

The Value is Integer : false

Example 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.

JavaScript
// Defining Lodash variable 
const _ = require('lodash');

// Checking for Integer
console.log("The Value is Integer : "
    + _.isInteger(Infinity));

Output:

The Value is Integer : false

Similar Reads