TypedArray.prototype.every()
TypedArray
实例的 every()
方法测试类型化数组中的所有元素是否通过所提供函数实现的测试。它返回一个布尔值。该方法与 Array.prototype.every()
的算法相同。
¥The every()
method of TypedArray
instances tests whether all elements in the typed array pass the test implemented by the provided function. It returns a Boolean value. This method has the same algorithm as Array.prototype.every()
.
Try it
语法
参数
返回值
描述
¥Description
详细信息请参见 Array.prototype.every()
。此方法不是通用的,只能在类型化数组实例上调用。
¥See Array.prototype.every()
for more details. This method is not generic and can only be called on typed array instances.
示例
测试所有类型数组元素的大小
¥Testing size of all typed array elements
以下示例测试类型化数组中的所有元素是否为 10 或更大。
¥The following example tests whether all elements in the typed array are 10 or bigger.
js
function isBigEnough(element, index, array) {
return element >= 10;
}
new Uint8Array([12, 5, 8, 130, 44]).every(isBigEnough); // false
new Uint8Array([12, 54, 18, 130, 44]).every(isBigEnough); // true
规范
Specification |
---|
ECMAScript Language Specification # sec-%typedarray%.prototype.every |
浏览器兼容性
BCD tables only load in the browser