Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. JavaScript
  3. JavaScript 参考
  4. JavaScript 标准内置对象
  5. BigInt64Array

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

BigInt64Array

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2021年9月⁩.

BigInt64Array 类型的数组代表由 64 位有符号整数组成的数组。如果需要控制字节顺序的话,请使用DataView 代替。内容初始化为0n。一旦建立,就可以使用对象的方法或使用标准数组索引语法(即使用中括号表示法)引用数组中的元素。

构造函数

BigInt64Array()

创建一个新的BigInt64Array 对象。

静态属性

BigInt64Array.BYTES_PER_ELEMENT

返回一个元素大小的数字值。BigInt64Array 返回8

静态方法

BigInt64Array.from()

从类数组或者可迭代对象创建一个新的BigInt64Array,另请参见Array.from()

BigInt64Array.of()

从可变数量的参数创建一个新的BigInt64Array,另请参见Array.of()

实例属性

BigInt64Array.prototype.buffer

返回被BigInt64Array 引用的ArrayBuffer。这在BigInt64Array 对象构建时期就被锁定了,所以是只读的

BigInt64Array.prototype.byteLength

返回BigInt64ArrayArrayBuffer 开始的长度(以字节为单位)。这在BigInt64Array 对象构建时期就被锁定了,所以是只读的

BigInt64Array.prototype.byteOffset

返回BigInt64ArrayArrayBuffer 开始的偏移量(以字节为单位)。这在BigInt64Array 对象构建时期就被锁定了,所以是只读的

BigInt64Array.prototype.length

返回BigInt64Array 中被保留的元素个数。这在BigInt64Array 对象构建时期就被锁定了,所以是只读的

实例方法

从其父接口TypedArray 继承实例方法。

示例

不同的方法去创建一个BigInt64Array

js
// From a lengthvar bigint64 = new BigInt64Array(2);bigint64[0] = 42n;console.log(bigint64[0]); // 42nconsole.log(bigint64.length); // 2console.log(bigint64.BYTES_PER_ELEMENT); // 8// From an arrayvar arr = new BigInt64Array([21n, 31n]);console.log(arr[1]); // 31n// From another TypedArrayvar x = new BigInt64Array([21n, 31n]);var y = new BigInt64Array(x);console.log(y[0]); // 21n// From an ArrayBuffervar buffer = new ArrayBuffer(32);var z = new BigInt64Array(buffer, 0, 4);// From an iterablevar iterable = (function* () {  yield* [1n, 2n, 3n];})();var bigint64 = new BigInt64Array(iterable);// BigInt64Array[1n, 2n, 3n]

规范

Specification
ECMAScript® 2026 Language Specification
# sec-typedarray-objects

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp