[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/DataView/setInt16 [Back]  [Original]

DataView.prototype.setInt16() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

DataView.prototype.setInt16()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

DataView setInt16() DataView 2 16 . , .

In this article

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);

const view = new DataView(buffer);
view.setInt16(1, 32767); // Max signed 16-bit integer

console.log(view.getInt16(1));
// Expected output: 32767

js
setInt16(byteOffset, value)
setInt16(byteOffset, value, littleEndian)

byteOffset

.

value

. .

littleEndian Optional

. false undefined .

undefined.

RangeError

byteOffset .

setInt16()

js
const buffer = new ArrayBuffer(10);
const dataview = new DataView(buffer);
dataview.setInt16(0, 3);
dataview.getInt16(1); // 768

Specification
ECMAScript 2027 LanguageSpecification
# sec-dataview.prototype.setint16


Web Proxy Viewer  |  New URL  |  Original Page