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/getint32/index.html | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/dataview/getint32') diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html new file mode 100644 index 0000000000..616d2b1977 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html @@ -0,0 +1,91 @@ +--- +title: DataView.prototype.getInt32() +slug: Web/JavaScript/Reference/Global_Objects/DataView/getInt32 +translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt32 +--- +
{{JSRef}}
+ +

getInt32()方法DataView相对于起始位置偏移 n 个字节处开始,获取一个32-bit数(长整型,4个字节).

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

语法

+ +
dataview.getInt32(byteOffset [, littleEndian])
+ +

参数

+ +
+
byteOffset
+
偏移量, 单位为字节, 从头开始计算.
+
littleEndian
+
{{optional_inline}} Indicates whether the 32-bit int is stored in {{Glossary("Endianness", "little- or big-endian")}} format. If false or undefined, a big-endian value is read.
+
+ +

返回

+ +
+
一个长整型32位数.
+
+ +

抛出错误

+ +
+
{{jsxref("RangeError")}}
+
如果byteOffset超出了视图能储存的值,就会抛出错误.
+
+ +

描述

+ +
+
 没有对齐约束; 多字节值可以从任何偏移量获取.
+
+ +

例子

+ +
var buffer = new ArrayBuffer(8);
+var dataview = new DataView(buffer);
+dataview.getInt32(1); // 0
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Typed Array')}}{{Spec2('Typed Array')}}Superseded by ECMAScript 6.
{{SpecName('ES6', '#sec-dataview.prototype.getint32', 'DataView.prototype.getInt32')}}{{Spec2('ES6')}}Initial definition in an ECMA standard.
{{SpecName('ESDraft', '#sec-dataview.prototype.getint32', 'DataView.prototype.getInt32')}}{{Spec2('ESDraft')}}
+ +

浏览器支持

+ + + +

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

+ +

另见

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