UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ DataView/ DataView() constructor

The DataView() constructor creates DataView objects.

Syntax

new DataView(buffer)
new DataView(buffer, byteOffset)
new DataView(buffer, byteOffset, byteLength)

Note: DataView() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

Return value

A new DataView object representing the specified data buffer.

Exceptions

Examples

Using DataView

const buffer = new ArrayBuffer(16);
const view = new DataView(buffer, 0);

view.setInt16(1, 42);
view.getInt16(1); // 42

Specifications

Browser compatibility

See also