Reference

Transfer vs clone

Move ownership instead of copying bytes. Companion to lesson 3. MDN: Transferable objects.

Two calls, one idea

// Same realm — explicit clone + optional move
const copy = structuredClone(u8, { transfer: [u8.buffer] });

// Other realm — implicit clone + optional move
worker.postMessage(u8, [u8.buffer]);

When to transfer

Hard problem Default
Large binary; sender is done with the bytes Transfer
Both sides still need the bytes Clone (or copy first, then transfer one copy)
Same-realm snapshot that must freeze the original structuredClone(value, { transfer }) — source detaches
BroadcastChannel / IndexedDB / History Clone only — no transfer list
Small objects, Dates, Maps, DTOs Clone; transfer is the wrong tool

Common transferables

ArrayBuffer, MessagePort, ImageBitmap, OffscreenCanvas, ReadableStream / WritableStream / TransformStream, VideoFrame, AudioData. Marked [Transferable] in Web IDL. Do not memorize the long tail — check MDN when a type is unfamiliar.