Thursday, September 4, 2025
HomeLanguagesJavascriptLodash _.some() Method

Lodash _.some() Method

Lodash _.some() method is used to check if the predicate returns true for any element of the collection. Iteration is stopped once the predicate returns true. 

Syntax: 

_.some(collection, [predicate])

Parameters:

  • collection (Array|Object) parameter holds the collection to iterate over.
  • predicate(Function) parameter holds the function invoked per iteration and is invoked with three arguments (value, index|key, collection).

Return value:

This method is used to return true if any element passes the predicate check, else false.

Example 1: In this example, It is returning true as it has passed the predicate check.

Javascript




// Requiring the lodash library
const _ = require("lodash");
      
// Original array and use of _.some() method
let gfg = _.some([null, 0, 'yes', false], Boolean);
 
// Printing the output
console.log(gfg);


 Output:  

true

Example 2: In this example, It is returning false as it has not passed the predicate check.

Javascript




// Requiring the lodash library
const _ = require("lodash");
 
// Original array
let object = [
    { 'obj': 'moto', 'active': true },
    { 'obj': 'lenovo', 'active': false }];
 
// Use of _.some() method
// The `_.matches` iteratee shorthand
 
let gfg = _.some(object, { 'obj': 'moto', 'active': false });
 
// Printing the output
console.log(gfg);


 Output:  

false

Example 3: In this example, It is returning true as it has passed the predicate check.

Javascript




// Requiring the lodash library
const _ = require("lodash");
 
// Original array
 
let object = [
    { 'obj': 'moto', 'active': true },
    { 'obj': 'lenovo', 'active': false }];
 
// Use of _.some() method
// The `_.matchesProperty` iteratee shorthand
 
let gfg = _.some(object, ['active', false]);
 
// Printing the output
console.log(gfg);


 Output:  

true

Example 4: In this example, It is returning true as it has passed the predicate check.

Javascript




// Requiring the lodash library
const _ = require("lodash");
 
// Original array
let object = [
    { 'obj': 'moto', 'active': true },
    { 'obj': 'lenovo', 'active': false }];
 
// Use of _.some() method
// The `_.property` iteratee shorthand
 
let gfg = _.some(object, 'active');
 
// Printing the output
console.log(gfg);


 Output:  

true
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!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11859 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6717 POSTS0 COMMENTS