Open In App

Lodash _.isNil() Method

Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.isNil() method is used to check if the value is null or undefined. If the value is nullish then returns true otherwise it returns false.

Syntax:

_.isNil(value)

Parameters:

  • value(*) parameter holds the value to check.

Return Value:

This method returns true if the value is nullish, else false.

Example 1: In this example, null is null itself so it is returning true.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
    
// Use of _.isNil() 
// method
let gfg = _.isNil(null);
        
// Printing the output 
console.log(gfg);


 Output:

true

Example 2: In this example, void is null so it is returning the true value.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
    
// Use of _.isNil() 
// method
let gfg = _.isNil(void 0);
        
// Printing the output 
console.log(gfg);


 Output:

true

Example 3: In this example, NaN is not null so it is giving us a false value.

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
    
// Use of _.isNil() 
// method
let gfg = _.isNil(NaN);
        
// Printing the output 
console.log(gfg);


Output:

false 


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