CKTIS / JavaScript
Array.prototype.some: testing whether any element matches
some stops at the first truthy callback result and reports whether an existing element matched.
Version: ECMAScript 2026 draft; example target: Node.js 24.22.2
Syntax
array.some(callbackFn[, thisArg])array.some(callbackFn[, thisArg]) visits existing indexes in ascending order and calls callbackFn(value, index, array). It immediately returns true for the first truthy result; otherwise it returns false. An empty array produces false, and sparse holes are skipped.
Length is captured before the first call: elements appended beyond it are not visited, while an index deleted in time is skipped. thisArg supplies this to an ordinary function, not an arrow function. The method itself does not mutate and is generic for array-like values. A non-callable callback or null or undefined receiver throws TypeError; callback failures propagate.
Examples
const visited = [];
const sparse = [, 3, 8, 10];
const found = sparse.some((value, index, array) => {
visited.push(index);
if (index === 1) array.push(12);
return value % 2 === 0;
});
console.log(found, visited.join(","), sparse.length);
console.log([].some(() => true));
const limit = { value: 5 };
console.log([2, 6].some(function (value) { return value > this.value; }, limit));Result
true 1,2 5 false true