Open In App

Lodash _.isFinite() Method

Lodash _.isFinite() method checks whether the given value is a primitive finite number or not and returns the corresponding boolean value.

Syntax:

_.isFinite(value);

 Parameters:

Return Value:

This method returns a Boolean value(Returns true if the given value is a finite number, else false).



Example 1: In this example, we are checking whether the given value is a finite number or not.




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Finite Value
console.log("The Value is Finite : "
    + _.isFinite(10));

Output:



The Value is Finite : true

Example 2:  In this example, we are checking whether the given value is a finite number or not. for Infinity, it returns false.




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Finite Value
console.log("The Value is Finite : "
    + _.isFinite(Infinity));

Output:

The Value is Finite : false 

Example 3: In this example, we are checking whether the given value is a finite number or not. for strings, it returns false.




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Finite Value
console.log("The Value is Finite : "
    + _.isFinite("gfg"));

Output:

The Value is Finite : false 

Example 4: In this example, we are checking whether the given value is a finite number or not.




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Finite Value
console.log("The Value is Finite : "
    + _.isFinite(Number.MAX_VALUE));

Output:

The Value is Finite : true

Article Tags :