Array.every(callback) Last updated: 24. Jan 2023

Calls a function for every item in an array, stops when return result is false.

Parameters

Name Type Description
callback function

Returns

A bool if every item returned true.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
const items = ["abc", "def", "ghi"];
var result = items.every(x => {
    write(x);
    return !x.startsWith("d"); /* Iteration will stop after item 2 */
});

write("\n");
write("Result: " + result);

Output

The JS code above produces the output shown below:
abcdef
Result: False