every

Summary

Tests if the specified condition is valid for every array element.

Signatures

Click on a signature to select it and view its documentation.

Usage

public bool every(bool(T currentValue) callback)

Returns

true if all array elements satisfy the specified condition and false otherwise.

Parameters

callback

A function which provides the test logic.

Description

Tests if the specified condition is valid for every array element.

This method was standardized in ECMAScript 5 for JavaScript. For web browsers that do not support ECMAScript 5, JS++ will provide a polyfill for this method only if it is used.

Examples

Basic Usage
1
2
3
4
5
6
7
import System;
 
int[] oddNumbers = [ 1, 3, 5 ];
bool onlyOddNumbers = oddNumbers.every(bool(int currentValue) {
    return currentValue % 2 == 1;
});
Console.log(onlyOddNumbers); // true

Share

HTML | BBCode | Direct Link