// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
const view = new DataView(buffer);
view.setUint16(1, 65535); // Max unsigned 16-bit integer
console.log(view.getUint16(1));
// Expected output: 65535
JavaScript Demo: DataView.setUint16()
9
1
2
3
4
5
6
7
8
9
// Create an ArrayBuffer with a size in bytes
constbuffer=newArrayBuffer(16);
constview=newDataView(buffer);
view.setUint16(1, 65535); // Max unsigned 16-bit integer