DataView.prototype.setBigUint64()

DataView 实例的 setBigUint64() 方法采用 BigInt 并将其作为 64 位无符号整数存储在从该 DataView 的指定字节偏移量开始的 8 个字节中。没有对齐约束;多字节值可以存储在边界内的任何偏移处。

¥The setBigUint64() method of DataView instances takes a BigInt and stores it as a 64-bit unsigned integer in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds.

Try it

语法

¥Syntax

js
setBigUint64(byteOffset, value)
setBigUint64(byteOffset, value, littleEndian)

参数

¥Parameters

byteOffset

距存储数据的视图开头的偏移量(以字节为单位)。

value

要设置为 BigInt 的值。有关如何以字节为单位对值进行编码的信息,请参阅 值编码和标准化

littleEndian Optional

表示数据是否以 小端或大端 格式存储。如果是 falseundefined,则写入大端值。

返回值

¥Return value

undefined

例外情况

¥Exceptions

RangeError

如果 byteOffset 设置为存储在视图末尾之外,则抛出此异常。

示例

¥Examples

使用 setBigUint64()

¥Using setBigUint64()

js
const buffer = new ArrayBuffer(10);
const dataview = new DataView(buffer);
dataview.setBigUint64(0, 3n);
dataview.getBigUint64(1); // 768n

规范

Specification
ECMAScript Language Specification
# sec-dataview.prototype.setbiguint64

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看