DataView.prototype.getBigUint64()
DataView 例項的 getBigUint64() 方法會讀取此 DataView 中指定位元組偏移量開始的 8 個位元組,並將它們解釋為 64 位無符號整數。該方法沒有位元組對齊限制;多位元組值可以從任何邊界內的偏移量處獲取。
試一試
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
// Highest possible BigInt value that fits in an unsigned 64-bit integer
const max = 2n ** 64n - 1n;
const view = new DataView(buffer);
view.setBigUint64(1, max);
console.log(view.getBigUint64(1));
// Expected output: 18446744073709551615n
語法
js
getBigUint64(byteOffset)
getBigUint64(byteOffset, littleEndian)
引數
byteOffset-
要從中讀取資料的檢視起始位置的位元組偏移量。
littleEndian可選-
指示資料是以小端序或大端序格式儲存的。如果為
false或undefined,則讀取大端序值。
返回值
一個 0 到 264-1(含)的 BigInt。
異常
RangeError-
如果
byteOffset設定為讀取超出檢視末尾,則會丟擲此錯誤。
示例
使用 getBigUint64()
js
const { buffer } = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
const dataview = new DataView(buffer);
console.log(dataview.getBigUint64(1)); // 72623859790382856n
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-dataview.prototype.getbiguint64 |
瀏覽器相容性
載入中…