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. public bool every(bool(T currentValue) callback) public bool every(bool(T currentValue, int index) callback) public bool every(bool(T currentValue, int index, T[] array) callback) Usage public bool every(bool(T currentValue) callback) public bool every(bool(T currentValue, int index) callback) public bool every(bool(T currentValue, int index, T[] array) callback) Returns true if all array elements satisfy the specified condition and false otherwise. true if all array elements satisfy the specified condition and false otherwise. true if all array elements satisfy the specified condition and false otherwise. Parameters callback A function which provides the test logic. Parameters callback A function which provides the test logic. 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. 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. 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 1234567import System; int[] oddNumbers = [ 1, 3, 5 ];bool onlyOddNumbers = oddNumbers.every(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(onlyOddNumbers); // true Basic Usage 1234567import System; int[] oddNumbers = [ 1, 3, 5 ];bool onlyOddNumbers = oddNumbers.every(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(onlyOddNumbers); // true Logging the current array index on each iteration 12345678import System; int[] oddNumbers = [ 1, 3, 5 ];bool onlyOddNumbers = oddNumbers.every(bool(int currentValue, int index) { Console.log("index: " + index.toString()); return currentValue % 2 == 1;});Console.log(onlyOddNumbers); // true Basic Usage 1234567import System; int[] oddNumbers = [ 1, 3, 5 ];bool onlyOddNumbers = oddNumbers.every(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(onlyOddNumbers); // true Access original array inside callback 123456789import System;import System.Assert; int[] oddNumbers = [ 1, 3, 5 ];bool onlyOddNumbers = oddNumbers.every(bool(int currentValue, int index, int[] array) { assert(currentValue == array[index]); return array[index] % 2 == 1;});Console.log(onlyOddNumbers); // true Share HTML | BBCode | Direct Link