From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/dataview/setbigint64/index.html | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/dataview/setbigint64/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/dataview/setbigint64') diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/setbigint64/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/setbigint64/index.html new file mode 100644 index 0000000000..5e9b6596d4 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/setbigint64/index.html @@ -0,0 +1,84 @@ +--- +title: DataView.prototype.setBigInt64() +slug: Web/JavaScript/Reference/Global_Objects/DataView/setBigInt64 +tags: + - BigInt + - DataView + - setBigInt64 +translation_of: Web/JavaScript/Reference/Global_Objects/DataView/setBigInt64 +--- +
{{JSRef}}
+ +

setBigInt64()方法在距{{jsxref("DataView")}} 的起始位置的指定字节偏移处存储一个带符号的64位整数(long long类型)值。

+ +
{{EmbedInteractiveExample("pages/js/dataview-setbigint64.html")}}
+ + + +

语法

+ +
dataview.setBigInt64(byteOffset, value [, littleEndian])
+ +

参数说明

+ +
+
byteOffset
+
字节偏移量,为从视图的起始位置到数据存储位置的字节字节偏移量。
+
+
value
+
作为一个{{jsxref("BigInt")}}类型设置的数值。满足一个带符号的64位整数的最大可能数值是 2n ** (64n -1n) - 1n (9223372036854775807n)。当发生溢出时,将会变成负数(-9223372036854775808n)。
+
littleEndian
+
{{optional_inline}} 为可选参数,表示这个64位整数是否以{{Glossary("Endianness", "little-endian 或者big-endian")}}格式存储。如果设置为false 或者未指定(undefined),将会写入一个big-endian(大端模式:高位字节排放在内存的低地址端,低位字节排放在内存的高地址端)格式的数值。
+
+ +

返回值

+ +

{{jsxref("undefined")}}.

+ +

抛出的错误

+ +
+
{{jsxref("RangeError")}}
+
如果 byteOffset设置导致存储该数值时超出了视图的末尾位置,将会抛出错误。
+
+ +

例子

+ +

使用 setBigInt64 方法

+ +
var buffer = new ArrayBuffer(8);
+var dataview = new DataView(buffer);
+dataview.setBigInt64(0, 3n);
+dataview.getBigInt64(0); // 3n
+
+ +

相关规范

+ + + + + + + + + + + + + + +
规范状态解释
{{SpecName('ESDraft', '#sec-dataview.prototype.setbigint64', 'DataView.prototype.setBigInt64()')}}{{Spec2('ESDraft')}}    
+ +

浏览器兼容性

+ + + +

{{Compat("javascript.builtins.DataView.setBigInt64")}}

+ +

请参阅

+ + -- cgit v1.2.3-54-g00ecf