DataView.prototype.getBigUint64()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
DataView
的 getBigUint64()
方法,从 DataView
的指定的字节偏移量位置读取 8 个字节,并将其解析为一个无符号 64 位整数(unsigned long long)。
尝试一下
// 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
可选-
指示 64 位整数是以小端还是大端格式存储。如果值为
false
或undefined
,则以大端格式读取。
返回值
一个 BigInt
。
异常
RangeError
-
如果
byteOffset
设置导致读取时超出了视图的末尾位置,则抛出该错误。
描述
没有对齐约束,可以从任意偏移量获取多字节值。
示例
使用 getBigUint64
方法
js
const buffer = new ArrayBuffer(8);
const dataview = new DataView(buffer);
dataview.getBigUint64(0); // 0n
规范
Specification |
---|
ECMAScript® 2025 Language Specification # sec-dataview.prototype.getbiguint64 |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getBigUint64 |
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.