UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ DataView/ DataView.prototype.setInt16()

The setInt16() method of DataView instances takes a number and stores it as a 16-bit signed integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds.

Syntax

setInt16(byteOffset, value)
setInt16(byteOffset, value, littleEndian)

Parameters

Return value

undefined.

Exceptions

Examples

Using setInt16()

const buffer = new ArrayBuffer(10);
const dataview = new DataView(buffer);
dataview.setInt16(0, 3);
dataview.getInt16(1); // 768

Specifications

Browser compatibility

See also