Open In App

Lodash _.isFinite() Method

Improve
Improve
Like Article
Like
Save
Share
Report

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:

  • value: This parameter holds the value that is to be checked for a primitive finite number.

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.

Javascript




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

Javascript




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

Javascript




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

Javascript




// 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


Last Updated : 03 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads