This page was translated from English by the community.Learn more and join the MDN Web Docs community.
DataView.prototype.getInt8()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
DataView 인스턴스의getInt8() 메서드는 이DataView의 지정된 바이트 오프셋에서1바이트를 읽고 이를 8비트 부호 있는 정수로 해석합니다.
In this article
시도해 보기
// Create an ArrayBuffer with a size in bytesconst buffer = new ArrayBuffer(16);const view = new DataView(buffer);view.setInt8(1, 127); // Max signed 8-bit integerconsole.log(view.getInt8(1));// Expected output: 127구문
js
getInt8(byteOffset)매개변수
byteOffset데이터를 읽을 데이터 뷰의 시작점으로부터의 오프셋(바이트).
반환 값
-128 이상 127 이하의 정수
예외
RangeError데이터 뷰의 끝을 넘어서 읽을 수 있는
byteOffset이 설정된 경우 발생합니다.
예제
>getInt8() 메서드 사용하기
js
const { buffer } = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);const dataview = new DataView(buffer);console.log(dataview.getInt8(1)); // 1명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-dataview.prototype.getint8> |