DataView.prototype.getUint8()
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
인스턴스의 getUint8()
메서드는 이 DataView
의 지정된 바이트 오프셋에서
1바이트를 읽고 이를 8비트 부호 없는 정수로 해석합니다.
시도해보기
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
const view = new DataView(buffer);
view.setUint8(1, 255); // Max unsigned 8-bit integer
console.log(view.getUint8(1));
// Expected output: 255
구문
js
getUint8(byteOffset)
매개변수
byteOffset
-
데이터를 읽을 뷰의 시작 부분으로부터의 오프셋(바이트 단위)입니다.
반환 값
0 이상 255 이하의 정수.
예외
RangeError
-
뷰의 끝을 넘어 읽는 수도 있는
byteOffset
이 설정된 경우 발생합니다.
설명
정렬 제약 조건은 없으며, 임의의 오프셋에서 멀티바이트 값을 가져올 수 있습니다.
예제
getUint8() 메서드 사용하기
js
const { buffer } = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
const dataview = new DataView(buffer);
console.log(dataview.getUint8(1)); // 1
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-dataview.prototype.getuint8 |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getUint8 |
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.