How to use Lodash isFinite() and _.isNaN() Methods In Javascript
In this example, we are using Lodash’s function to check whether the given number is finite or NaN.
Example: This example shows the implementation of above- explained approach.
Javascript
// Defining Lodash variable const _ = require( 'lodash' ); let a = 10; if (_.isFinite(a)) console.log( " it is a finite number" ); if (_.isNaN(a)) console.log( " It is NaN" ) |
Output:
it is a finite number
How to check whether a number is NaN or finite in JavaScript ?
In this article, we will see how to check whether the number is NaN or finite. To check whether the given number is NaN or finite, we can use JavaScript methods.
These are the following methods for solving this problem:
Table of Content
- Using isNaN() Method
- Using isFinite() Method
- Using Lodash isFinite() and _.isNaN() Methods