Related Articles

Related Articles

Lodash _.isNaN() Method
  • Last Updated : 16 Sep, 2020

The Lodash _.isNaN() Method checks the given value is NaN or not. This method is not the same as the JavaScript isNaN() method which returns true for undefined and other non-number values.

Syntax:

_.isNaN( value )

Parameters: This method accepts a single parameter as mentioned above and described below:

  • value: This parameter holds the value that need to be checked for NaN.

Return Value: This method returns a Boolean value (Returns true if the value is NaN, else false).

Example 1: 



Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking
console.log(_.isNaN(NaN));

chevron_right


Output:

true

Example 2: For checking with an empty source this method returns true.

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking
console.log(_.isNaN(new Number(NaN)));

chevron_right


Output:

true

Example 3: This method also works for arrays.

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Defining Lodash variable 
const _ = require('lodash'); 
  
// Checking
console.log(_.isNaN(undefined)); 
  
// Checking
console.log(_.isNaN(10));

chevron_right


Output:

false
false

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :