Standard built-ins
ArrayBuffer.prototype.resize()
Resizes a resizable ArrayBuffer within maxByteLength; throws for invalid sizes or fixed buffers.
Formal Syntax & Structure
javascript syntaxjavascript
buffer.resize(newByteLength)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| newByteLength | number | New byte length within maximum. |
Return Value
undefined
Resizes a resizable ArrayBuffer within maxByteLength; throws for invalid sizes or fixed buffers.
Working Example
Example Snippetjavascript
(async () => {const b=new ArrayBuffer(2,{maxByteLength:4});b.resize(4);console.log(b.byteLength,b.resizable,JSON.stringify([...new Uint8Array(b)]));})()