Standard built-ins

DataView.prototype.getUint16()

Try the free JavaScript compiler

Reads an unsigned 16-bit value at a byte offset; false or omitted means big-endian.

Formal Syntax & Structure

javascript syntaxjavascript
view.getUint16(byteOffset, littleEndian)

Parameters & Attributes

NameTypeDescription
byteOffsetnumberField offset in bytes.
littleEndianbooleanUse little-endian when true.

Return Value

number

Reads an unsigned 16-bit value at a byte offset; false or omitted means big-endian.

Working Example

Example Snippetjavascript
(async () => {const v=new DataView(new Uint8Array([1,2]).buffer);console.log(v.getUint16(0),v.getUint16(0,true));})()
JavaScript Reference