Web APIs
Transferable buffer ownership
Transfers a transferable ArrayBuffer through the host clone algorithm; the original is detached.
Formal Syntax & Structure
javascript syntaxjavascript
structuredClone(buffer, {transfer: [buffer]})Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| buffer | ArrayBuffer | Transferable 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)]));})()