ArrayBuffer.isView()

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

Syntax

js

ArrayBuffer.isView(value)

Parameters

value

The value to be checked.

Return value

true if the given argument is one of the ArrayBuffer views; otherwise, false.

Examples

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

Specifications

Specification
ECMAScript Language Specification
# sec-arraybuffer.isview

Browser compatibility

BCD tables only load in the browser

See also