Open In App

Lodash _.falsey() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The Lodash _.falsey() method checks whether the given value is falsey or not and returns the corresponding boolean value. A falsey value is one that means false in a boolean context.

Syntax:

_.falsey( value );

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

  • value: Given value is to be checked for falsey value.

Return Value: This method returns a Boolean value true if the given value is falsey, else false.

Note: This will not work in normal JavaScript because it requires the lodash.js contrib library to be installed. Lodash.js contrib library can be installed using npm install lodash-contrib.

Example 1:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.falsey(false);
    
console.log("Given Value is Falsey : ", bool);


Output:

Given Value is Falsey : true

Example 2:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.falsey(10);
    
console.log("Given Value is Falsey : ", bool);


Output:

Given Value is Falsey : false

Example 3:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.falsey([ 1, 2, 3 ]);
console.log("Given Value is Falsey : ", bool);
  
var bool = _.falsey({});
console.log("Given Value is Falsey : ", bool);


Output:

Given Value is Falsey : false
Given Value is Falsey : false

Example 4:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.falsey(false);
console.log("Given Value is Falsey : ", bool);
  
var bool = _.falsey("false");
console.log("Given Value is Falsey : ", bool);


Output:

Given Value is Falsey : true
Given Value is Falsey : false


Last Updated : 30 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads