HTTP/2 302
x-cloud-trace-context: d4d159b8fd6c590092b3152d78c5445f
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: Sat, 27 Dec 2025 05:15:35 GMT
x-served-by: cache-bfi-krnt7300094-BFI, cache-bfi-krnt7300048-BFI, cache-sin-wsss1830066-SIN, cache-bom-vanm7210085-BOM
x-cache: MISS, MISS, MISS, MISS
x-cache-hits: 0, 0, 0, 0
x-timer: S1766812535.076602,VS0,VE324
vary: Accept
content-length: 92
HTTP/2 200
x-goog-meta-goog-reserved-file-mtime: 1766796589
x-goog-hash: crc32c=2FAdeA==, md5=O5tAZnld/XIogWWGaoT6ng==
x-goog-generation: 1766797587179140
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish
x-goog-stored-content-encoding: identity
x-goog-metageneration: 1
referrer-policy: strict-origin-when-cross-origin
strict-transport-security: max-age=63072000
x-goog-stored-content-length: 150692
expires: Sat, 27 Dec 2025 04:30:48 GMT
x-content-type-options: nosniff
content-type: text/html
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-cloud-trace-context: 9ca287b5e76c4e01f965222edcc060a1
cache-control: public, max-age=3600
last-modified: Sat, 27 Dec 2025 01:06:27 GMT
x-guploader-uploadid: AHVrFxPJ3znmgbtfi649euqh9iIYUKibLScJU6wRA6gOi8hpNqw0pUJoP5OhVD1gN98lt16cIoSgTMA
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-goog-storage-class: STANDARD
etag: "3b9b4066795dfd72288165866a84fa9e"
x-frame-options: DENY
server: Google Frontend
content-encoding: gzip
accept-ranges: bytes
age: 2597
date: Sat, 27 Dec 2025 05:15:35 GMT
x-served-by: cache-sin-wsss1830048-SIN, cache-sin-wsss1830032-SIN, cache-bom-vanm7210085-BOM
x-cache: MISS, HIT, MISS
x-cache-hits: 0, 1, 0
x-timer: S1766812535.419460,VS0,VE61
vary: Accept-Encoding
content-length: 19891
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.