DataView.prototype.setInt8()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
DataView
인스턴스의 setInt8()
메서드는 숫자를 받아 이 DataView
의 지정된 바이트 오프셋에 있는 바이트에 8비트 부호 있는 정수로 저장합니다.
시도해보기
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
const view = new DataView(buffer);
view.setInt8(1, 127); // Max signed 8-bit integer
console.log(view.getInt8(1));
// Expected output: 127
구문
js
setInt8(byteOffset, value)
매개변수
byteOffset
-
데이터를 저장할 데이터 뷰의 시작점으로부터의 바이트 단위의 오프셋.
value
-
저장할 값. 어떻게 값이 바이트로 인코딩되는지는 값 인코딩 및 정규화를 보시기 바랍니다.
반환 값
예외
RangeError
-
뷰의 끝을 넘어서 저장하려고 하는 경우에 byteOffset이 설정되면 발생합니다.
예제
setInt8() 사용하기
js
const buffer = new ArrayBuffer(10);
const dataview = new DataView(buffer);
dataview.setInt8(0, 3);
dataview.getInt8(0); // 3
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-dataview.prototype.setint8 |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setInt8 |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.