some Summary Tests if the specified condition is valid for at least one array element. Signatures Click on a signature to select it and view its documentation. public bool some(bool(T currentValue) callback) public bool some(bool(T currentValue, int index) callback) public bool some(bool(T currentValue, int index, T[] array) callback) Usage public bool some(bool(T currentValue) callback) public bool some(bool(T currentValue, int index) callback) public bool some(bool(T currentValue, int index, T[] array) callback) Returns true if at least one array element satisfies the specified condition and false otherwise. true if at least one array element satisfies the specified condition and false otherwise. true if at least one array element satisfies 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 at least one 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 at least one 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 at least one 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[] numbers = [ 2, 3, 4, 6, 8, 10 ];bool containsOdd = numbers.some(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(containsOdd); // true Basic Usage 1234567import System; int[] numbers = [ 2, 3, 4, 6, 8, 10 ];bool containsOdd = numbers.some(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(containsOdd); // true Logging the current array index on each iteration 12345678import System; int[] numbers = [ 2, 3, 4, 6, 8, 10 ];bool containsOdd = numbers.some(bool(int currentValue, int index) { Console.log("index: " + index.toString()); return currentValue % 2 == 1;});Console.log(containsOdd); // true Basic Usage 1234567import System; int[] numbers = [ 2, 3, 4, 6, 8, 10 ];bool containsOdd = numbers.some(bool(int currentValue) { return currentValue % 2 == 1;});Console.log(containsOdd); // true Access original array inside callback 123456789import System;import System.Assert; int[] numbers = [ 2, 3, 4, 6, 8, 10 ];bool containsOdd = numbers.some(bool(int currentValue, int index, int[] array) { assert(currentValue == array[index]); return array[index] % 2 == 1;});Console.log(containsOdd); // true Share HTML | BBCode | Direct Link