--- title: ArrayBuffer.isView() slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView tags: - 类型数组 - 缓冲区 translation_of: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView ---
ArrayBuffer.isView()
方法用来判断传入的参数值是否是一种 ArrayBuffer
视图(view),比如类型化数组对象(typed array objects)或者数据视图( {{jsxref("DataView")}})。
ArrayBuffer.isView(value)
value
true
false
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 var buffer = new ArrayBuffer(2); var dv = new DataView(buffer); ArrayBuffer.isView(dv); // true
Specification | Status | Comment |
---|---|---|
{{SpecName('Typed Array')}} | {{Spec2('Typed Array')}} | Superseded by ECMAScript 6. |
{{SpecName('ES6', '#sec-arraybuffer.isview', 'ArrayBuffer.isView')}} | {{Spec2('ES6')}} | Initial definition in an ECMA standard. |
{{Compat("javascript.builtins.ArrayBuffer.isView")}}