new ArrayBuffer(length) allocates zero-filled bytes; slice() copies a range and ArrayBuffer.isView() detects views. ES2024 (Baseline 2024) added resizable buffers: pass { maxByteLength }, then resize(n) grows or shrinks in place, zero-filling new bytes, and a view created without a length tracks the size. It also added transfer(newLength?), which moves the bytes into a new buffer and detaches the original (byteLength 0, views empty); transferToFixedLength() always returns a non-resizable result.
const buf = new ArrayBuffer(4, { maxByteLength: 16 });
const view = new Uint8Array(buf); // no length: tracks the buffer's size
view.set([1, 2, 3, 4]);
buf.resize(6);
console.log(buf.byteLength, view.length, view);
const moved = buf.transfer(); // detaches buf, keeps resizability
console.log(buf.detached, view.length, moved.resizable, moved.maxByteLength);
const fixed = moved.transferToFixedLength(2);
console.log(fixed.resizable, new Uint8Array(fixed), moved.detached, ArrayBuffer.isView(view));6 6 Uint8Array(6) [ 1, 2, 3, 4, 0, 0 ] true 0 true 16 false Uint8Array(2) [ 1, 2 ] true true