some
Modified on Mon, 07 Aug 2023
Description
Return true if any of the array elements pass the test provided by the expression, otherwise false.
Syntax
some(array, element, expression)
Parameters
Input Parameter | Type | Description |
---|---|---|
array | Array | The array some() was called upon |
element | any | The current element being processed in the array |
expression | expression | A boolean expression to be run for each array element. |
Return value
Type |
---|
boolean |
Sample
Example | Result | Description |
---|---|---|
some([1, 2, 3], x, x > 2) | true | Check if at least one element is greater than 2 |
some([{'name' : 'John', 'age' : 18},{'name' : 'Raj', 'age' : 25}], x, x.age > 18) | true | Check if at least one of the user's age is greater than 18 |
To view all the List functions, click here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article