setBigInt64()
方法在距DataView
的起始位置的指定字节偏移处存储一个带符号的64位整数(long long类型)值。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
语法
dataview.setBigInt64(byteOffset, value [, littleEndian])
参数说明
- byteOffset
- 字节偏移量,为从视图的起始位置到数据存储位置的字节字节偏移量。
- value
-
作为一个
BigInt
类型设置的数值。满足一个带符号的64位整数的最大可能数值是2n ** (64n -1n) - 1n
(9223372036854775807n
)。当发生溢出时,将会变成负数(-9223372036854775808n
)。 - littleEndian
-
可选 为可选参数,表示这个64位整数是否以
little-endian 或者big-endian格式存储。如果设置为
false
或者未指定(undefined
),将会写入一个big-endian(大端模式:高位字节排放在内存的低地址端,低位字节排放在内存的高地址端)格式的数值。
返回值
抛出的错误
-
RangeError
-
如果
byteOffset
设置导致存储该数值时超出了视图的末尾位置,将会抛出错误。
例子
使用 setBigInt64
方法
var buffer = new ArrayBuffer(8); var dataview = new DataView(buffer); dataview.setBigInt64(0, 3n); dataview.getBigInt64(0); // 3n
相关规范
规范 | 状态 | 解释 |
---|---|---|
ECMAScript Latest Draft (ECMA-262) DataView.prototype.setBigInt64() |
Draft |
浏览器兼容性
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.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setBigInt64 |
Chrome Full support 67 | Edge No support No | Firefox Full support 68 | IE No support No | Opera Full support 54 | Safari No support No | WebView Android Full support 67 | Chrome Android Full support 67 | Firefox Android Full support 68 | Opera Android Full support 48 | Safari iOS No support No | Samsung Internet Android Full support 9.0 | nodejs Full support 10.4.0 |
Legend
- Full support
- Full support
- No support
- No support