ArrayBuffer.isView()
ArrayBuffer.isView()
静态方法确定传递的值是否是 ArrayBuffer
视图之一,例如 类型化数组对象 或 DataView
。
¥The ArrayBuffer.isView()
static method determines whether the
passed value is one of the ArrayBuffer
views,
such as typed array objects
or a DataView
.
Try it
语法
参数
返回值
¥Return value
true
如果给定参数是 ArrayBuffer
视图之一;否则,false
。
¥true
if the given argument is one of the ArrayBuffer
views;
otherwise, false
.
示例
使用 isView
¥Using isView
js
ArrayBuffer.isView(); // false
ArrayBuffer.isView([]); // false
ArrayBuffer.isView({}); // false
ArrayBuffer.isView(null); // false
ArrayBuffer.isView(undefined); // false
ArrayBuffer.isView(new ArrayBuffer(10)); // false
ArrayBuffer.isView(new Uint8Array()); // true
ArrayBuffer.isView(new Float32Array()); // true
ArrayBuffer.isView(new Int8Array(10).subarray(0, 3)); // true
const buffer = new ArrayBuffer(2);
const dv = new DataView(buffer);
ArrayBuffer.isView(dv); // true
规范
Specification |
---|
ECMAScript Language Specification # sec-arraybuffer.isview |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also