Sunday, October 19, 2025
HomeLanguagesJavascriptLodash _.exists() Method

Lodash _.exists() Method

The Lodash _.exists() method checks whether the given value is Exist or not and returns the corresponding boolean value. Both null and undefined are considered non-existy values. All other values are “Existy”.

Syntax:

_.exists( value );

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

  • value: Given value to be checked for Existy value.

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

Note: This will not work in normal JavaScript because it requires the lidash.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 = _.exists("Geeks");
    
console.log("Check the Existenc of Given Value : ", bool);


Output:

Check the Existenc of Given Value : true

Example 2:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.exists(undefined); 
    
console.log("Check the Existenc of Given Value : ", bool);


Output:

Check the Existenc of Given Value : false

Example 3:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.exists(null);
    
console.log("Check the Existenc of Given Value : ", bool);


Output:

Check the Existenc of Given Value : false

Example 4:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var bool = _.exists([1, 12, 2, 3]);
    
console.log("Check the Existenc of Given Value : ", bool);


Output:

Check the Existenc of Given Value : true
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS