Javascript DataView setInt16()

Introduction

The Javascript DataView setInt16() method stores a signed 16-bit integer value at the specified offset to DataView.

dataview.setInt16(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 setInt16 method

var buffer = new ArrayBuffer(8);
var dataview = new DataView(buffer);
dataview.setInt16(1, 3);/* ww w  .  j a v a  2 s  .  c om*/
let a = dataview.getInt16(1);
console.log(a);



PreviousNext

Related