HomeLanguagesJavascriptLodash _.falsey() Method

Lodash _.falsey() Method

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
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS