A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/DataView/getInt32 below:

DataView.prototype.getInt32() - JavaScript | MDN

DataView.prototype.getInt32()

Baseline Widely available

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

尝试一下
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);

const view = new DataView(buffer);
view.setInt32(1, 2147483647); // Max signed 32-bit integer

console.log(view.getInt32(1));
// Expected output: 2147483647
语法
dataview.getInt32(byteOffset [, littleEndian])
参数
byteOffset

偏移量,单位为字节,从头开始计算。

littleEndian

可选 Indicates whether the 32-bit int is stored in little- or big-endian format. If false or undefined, a big-endian value is read.

返回

一个长整型 32 位数。

抛出错误
RangeError

如果 byteOffset 超出了视图能储存的值,就会抛出错误。

描述

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

示例
var buffer = new ArrayBuffer(8);
var dataview = new DataView(buffer);
dataview.getInt32(1); // 0
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4