HTTP/2 302
x-cloud-trace-context: beecc48d92f6cdb7e235a5035062d81e
location: /en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
accept-ranges: bytes
cache-control: no-store
server: Google Frontend
content-type: text/plain; charset=utf-8
date: Mon, 29 Dec 2025 00:47:18 GMT
x-served-by: cache-bfi-krnt7300037-BFI, cache-bfi-krnt7300048-BFI, cache-sin-wsss1830066-SIN, cache-bom-vanm7210044-BOM
x-cache: MISS, MISS, MISS, MISS
x-cache-hits: 0, 0, 0, 0
x-timer: S1766969238.740559,VS0,VE286
vary: Accept
content-length: 92
HTTP/2 200
x-content-type-options: nosniff
cache-control: public, max-age=3600
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
x-cloud-trace-context: dd18399253364e3166cfd3f71114385e
server: Google Frontend
last-modified: Sun, 28 Dec 2025 01:10:28 GMT
referrer-policy: strict-origin-when-cross-origin
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
content-type: text/html
etag: "ad069a75210ec6595446be86dfa161e8"
strict-transport-security: max-age=63072000
expires: Mon, 29 Dec 2025 01:43:36 GMT
x-goog-meta-goog-reserved-file-mtime: 1766883288
x-goog-storage-class: STANDARD
x-frame-options: DENY
x-goog-metageneration: 1
x-goog-hash: crc32c=vSes5w==, md5=rQaadSEOxllURr6G36Fh6A==
x-guploader-uploadid: AHVrFxM8p_3J_60OytI43XVXRTxthZRaUu6niyZ8GKNfY7iudIvIQoI7lkHLKpLwPp55ayjEfDqam2w
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' mdn.github.io *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-goog-stored-content-encoding: identity
x-goog-generation: 1766884228709431
x-goog-stored-content-length: 150692
content-encoding: gzip
accept-ranges: bytes
age: 222
date: Mon, 29 Dec 2025 00:47:18 GMT
x-served-by: cache-bfi-krnt7300106-BFI, cache-bfi-krnt7300051-BFI, cache-sin-wsss1830032-SIN, cache-bom-vanm7210044-BOM
x-cache: MISS, HIT, MISS, MISS
x-cache-hits: 0, 1, 0, 0
x-timer: S1766969238.039814,VS0,VE325
vary: Accept-Encoding
content-length: 19889
ArrayBuffer.prototype.resize() - JavaScript | MDN
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
console.log(buffer.byteLength);
// Expected output: 8
buffer.resize(12);
console.log(buffer.byteLength);
// Expected output: 12
newLength
The new length, in bytes, to resize the ArrayBuffer to.
TypeError
Thrown if the ArrayBuffer is detached or is not resizable.
RangeError
Thrown if newLength is larger than the maxByteLength of the ArrayBuffer.
The resize() method resizes an ArrayBuffer to the size specified by the newLength parameter, provided that the ArrayBuffer is resizable and the new size is less than or equal to the maxByteLength of the ArrayBuffer. New bytes are initialized to 0.
Note that you can use resize() to shrink as well as grow an ArrayBuffer — it is permissible for newLength to be smaller than the ArrayBuffer's current byteLength .
In this example, we create a 8-byte buffer that is resizable to a max length of 16 bytes, then check its resizable property, resizing it if resizable returns true:
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });
if (buffer.resizable) {
console.log("Buffer is resizable!");
buffer.resize(12);
}
Enable JavaScript to view this browser compatibility table.