The Javascript BigInt64Array some()
method if some element in the typed array passes the test implemented by the provided function.
This method works the same as Array.prototype.some()
.
BigInt64Array.some(callback[, thisArg])
Parameter | Optional | Meaning |
---|---|---|
callback | Required | Function to test for each element Taking three arguments: currentValue - the current element being processed. index - the index of the current element being processed.array - the typed array itself. |
thisArg | Optional | Value to use as this when executing callback. |
It returns true if the callback function returns a truthy value for any array element; otherwise, false.
Testing size of all typed array elements
The following example tests whether any element in the typed array is bigger than 10.
function isBiggerThan10(element, index, array) { return element > 10; } let a = new BigInt64Array([2n, 5n, 8n, 1n, 4n]).some(isBiggerThan10); // false console.log(a); a = new BigInt64Array([12n, 5n, 8n, 1n, 4n]).some(isBiggerThan10); // true console.log(a);
Testing typed array elements using arrow functions
Arrow functions provide a shorter syntax for the same test.
let a = new BigInt64Array([2n, 5n, 8n, 1n, 4n]).some(elem => elem > 10); // false console.log(a);// w ww . j a v a 2s . co m a = new BigInt64Array([12n, 5n, 8n, 1n, 4n]).some(elem => elem > 10); // true console.log(a);