Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. TypedArray
  6. some()

TypedArray.prototype.some()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨September 2016⁩.

Thesome() method ofTypedArray instances returnstrue if it finds one element in the array that satisfies the provided testing function. Otherwise, it returnsfalse. This method has the same algorithm asArray.prototype.some().

Try it

function isNegative(element, index, array) {  return element < 0;}const int8 = new Int8Array([-10, 20, -30, 40, -50]);const positives = new Int8Array([10, 20, 30, 40, 50]);console.log(int8.some(isNegative));// Expected output: trueconsole.log(positives.some(isNegative));// Expected output: false

Syntax

js
some(callbackFn)some(callbackFn, thisArg)

Parameters

callbackFn

A function to execute for each element in the typed array. It should return atruthy value to indicate the element passes the test, and afalsy value otherwise. The function is called with the following arguments:

element

The current element being processed in the typed array.

index

The index of the current element being processed in the typed array.

array

The typed arraysome() was called upon.

thisArgOptional

A value to use asthis when executingcallbackFn. Seeiterative methods.

Return value

false unlesscallbackFn returns atruthy value for a typed array element, in which casetrue is immediately returned.

Description

SeeArray.prototype.some() for more details. This method is not generic and can only be called on typed array instances.

Examples

Testing size of all typed array elements

The following example tests whether any element in the typed array is bigger than 10.

js
function isBiggerThan10(element, index, array) {  return element > 10;}new Uint8Array([2, 5, 8, 1, 4]).some(isBiggerThan10); // falsenew Uint8Array([12, 5, 8, 1, 4]).some(isBiggerThan10); // true

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-%typedarray%.prototype.some

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp