The Javascript DataView setUint16() method stores an unsigned 16-bit integer value at the specified offset to the DataView.
dataview.setUint16(byteOffset, value [, littleEndian])
byteOffset
- the offset, in byte, from the start of the view.value
- the value to set.littleEndian
- Optional, boolean value. If false or undefined, a big-endian value is written. Otherwise use the little endian.Using the setUint16 method
var buffer = new ArrayBuffer(8); var dataview = new DataView(buffer); dataview.setUint16(1, 3);//from w w w . ja va2s.c o m let a = dataview.getUint16(1); console.log(a);// 3