[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some [Back]  [Original]

TypedArray.prototype.some() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

TypedArray.prototype.some()

20169

some() TypedArray Array.prototype.some() TypedArray typed array types

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: true

console.log(positives.some(isNegative));
// Expected output: false

js
some(callbackFn)
some(callbackFn, thisArg)

callback

3

currentValue

typed array

index

typed array

array

typed array

thisArg

callback this .

true callback truthy; false.

typed array some callbackcallback true some true. some false.

callback 3

some thisArg, thisArg callback this . callback this undefined. callback this this

some typed array .

typed array 10.

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

ECMAScript 2027 LanguageSpecification
# sec-%typedarray%.prototype.some


Web Proxy Viewer  |  New URL  |  Original Page