Standard built-ins

DataView.prototype.setInt32()

Try the free JavaScript compiler

Writes a signed 32-bit integer at an arbitrary byte offset. The entire value must fit in the view; otherwise a RangeError is thrown.

Formal Syntax & Structure

javascript syntaxjavascript
view.setInt32(byteOffset, value, littleEndian?)

Parameters & Attributes

NameTypeDescription
byteOffsetnumberStarting byte offset within the view.
valuenumberValue to encode as a signed 32-bit integer.
littleEndianbooleanTrue for little-endian; omitted or false means big-endian.

Return Value

undefined

Changes the bytes in the backing buffer.

Working Example

Example Snippetjavascript
const view=new DataView(new ArrayBuffer(5)); const result=view.setInt32(1,-123456,true); console.log(String(result),String(view.getInt32(1,true)));
JavaScript Reference