Web APIs

Transferable buffer ownership

Try the free JavaScript compiler

Transfers a transferable ArrayBuffer through the host clone algorithm; the original is detached.

Formal Syntax & Structure

javascript syntaxjavascript
structuredClone(buffer, {transfer: [buffer]})

Parameters & Attributes

NameTypeDescription
bufferArrayBufferTransferable source buffer.

Return Value

ArrayBuffer

Transfers a transferable ArrayBuffer through the host clone algorithm; the original is detached.

Working Example

Example Snippetjavascript
(async () => {const b=new Uint8Array([4,5]).buffer;const c=structuredClone(b,{transfer:[b]});console.log(b.byteLength,JSON.stringify([...new Uint8Array(c)]));})()
JavaScript Reference