Friday, January 23, 2026
HomeLanguagesJavascriptLodash _.firstExisting() Method

Lodash _.firstExisting() Method

The Lodash _.firstExisting() method returns the first existing argument from the arguments list.

Note: If the first argument is not exist like null or undefined, this method ignores that argument and checks for next.

Syntax:

_.firstExisting(arg1, arg2,....,argn);

Parameters: This method takes n arguments to check for the first existing argument.

Return Value: This method returns the first existing arguments.

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 f_exist = _.firstExisting("gfg", "abc", 0, 1);
    
console.log("First Existing value is : ", f_exist);


Output:

First Existing value is : gfg

Example 2:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var f_exist = _.firstExisting(null, 
        undefined, "gfg", "abc", 0, 1);
    
console.log("First Existing value is : ", f_exist);


Output:

First Existing value is : gfg

Example 3:

Javascript




// Defining underscore lodash variable 
var _ = require('lodash-contrib'); 
  
var f_exist = _.firstExisting( 1, 2, 2, 3, 3, 4 );
    
console.log("First Existing value is : ", f_exist);


Output:

First Existing value is : 1
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS