Array.some(evaluator) Last updated: 24. Jan 2023

Tests whether at least one element in the array returns true with provided evaluator function.

Parameters

Name Type Description
evaluator function Function to evaluate each item

Returns

Boolean, true if any items evaluates to true otherwise false.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
let items = ["apple", "banana", "lemon"];
let result = items.some(x => x.startsWith("b"));
write(result);

write("\n\n");

result = items.some(x => x.startsWith("x"));
write(result);

Output

The JS code above produces the output shown below:
True

False