Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
ArrayBuffer 物件是一種表示通用、固定大小的原始二進制資料緩衝。想要直接操作一個 ArrayBuffer 物件的內容是不可能的。若要讀寫該緩衝的內容則必須透過視圖,可以選擇建立一個 DataView 視圖物件或是一個限定其成員為某種型別的 TypedArray 視圖物件,它們皆能以特定的型別解讀、修改 ArrayBuffer。
要建立的緩衝陣列大小,以位元組(byte)計算。
為一個新建立的指定大小 ArrayBuffer 物件,其內容皆初始化為 0。
A RangeError is thrown if the length is larger than Number.MAX_SAFE_INTEGER (>= 2 ** 53) or negative.
The ArrayBuffer constructor creates a new ArrayBuffer of the given length in bytes.
The ArrayBuffer constructor's length property whose value is 1.
ArrayBuffer[Symbol.species]The constructor function that is used to create derived objects.
ArrayBuffer.prototypeAllows the addition of properties to all ArrayBuffer objects.
Returns true if arg is one of the ArrayBuffer views, such as typed array objects or a DataView. Returns false otherwise.
ArrayBuffer.transfer(oldBuffer [, newByteLength])Returns a new ArrayBuffer whose contents are taken from the oldBuffer's data and then is either truncated or zero-extended by newByteLength.
所有的 ArrayBuffer 物件實例皆繼承自 ArrayBuffer.prototype.
The initial value of the Symbol.toStringTag property is the string "ArrayBuffer". This property is used in Object.prototype.toString().
ArrayBuffer.prototype.byteLengthThe read-only size, in bytes, of the ArrayBuffer. This is established when the array is constructed and cannot be changed.
Returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes from begin (inclusive) up to end (exclusive). If either begin or end is negative, it refers to an index from the end of the array, as opposed to from the beginning.
In this example, we create a 8-byte buffer with a Int32Array view referring to the buffer:
| ECMAScript® 2027 Language Specification # sec-arraybuffer-objects |
Enable JavaScript to view this browser compatibility table.
Starting with ECMAScript 2015, ArrayBuffer constructors require to be constructed with a new operator. Calling an ArrayBuffer constructor as a function without new, will throw a TypeError from now on.
This page was last modified on 2025年7月14日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.