BigUint64Array
BigUint64Array 型別陣列表示平臺位元組序中的 64 位無符號整數陣列。如果需要控制位元組序,請改用 DataView。除非顯式提供初始化資料,否則其內容將初始化為 0n。一旦建立,您就可以使用該物件的方法或標準陣列索引語法(即使用方括號表示法)來引用陣列中的元素。
BigUint64Array 是隱藏的 TypedArray 類的子類。
建構函式
BigUint64Array()-
建立一個新的
BigUint64Array物件。
靜態屬性
也繼承了其父類 TypedArray 的靜態屬性.
BigUint64Array.BYTES_PER_ELEMENT-
返回元素大小的數字值。對於
BigUint64Array,該值為8。
靜態方法
繼承了其父類 TypedArray 的靜態方法.
例項屬性
也繼承了其父類 TypedArray 的例項屬性.
這些屬性定義在 BigUint64Array.prototype 上,並由所有 BigUint64Array 例項共享。
BigUint64Array.prototype.BYTES_PER_ELEMENT-
返回元素大小的數字值。對於
BigUint64Array,該值為8。 BigUint64Array.prototype.constructor-
建立例項物件的建構函式。對於
BigUint64Array例項,初始值為BigUint64Array建構函式。
例項方法
繼承了其父類 TypedArray 的例項方法.
示例
建立 BigUint64Array 的不同方法
js
// From a length
const biguint64 = new BigUint64Array(2);
biguint64[0] = 42n;
console.log(biguint64[0]); // 42n
console.log(biguint64.length); // 2
console.log(biguint64.BYTES_PER_ELEMENT); // 8
// From an array
const x = new BigUint64Array([21n, 31n]);
console.log(x[1]); // 31n
// From another TypedArray
const y = new BigUint64Array(x);
console.log(y[0]); // 21n
// From an ArrayBuffer
const buffer = new ArrayBuffer(64);
const z = new BigUint64Array(buffer, 8, 4);
console.log(z.byteOffset); // 8
// From an iterable
const iterable = (function* () {
yield* [1n, 2n, 3n];
})();
const biguint64FromIterable = new BigUint64Array(iterable);
console.log(biguint64FromIterable);
// BigUint64Array [1n, 2n, 3n]
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-typedarray-objects |
瀏覽器相容性
載入中…