postMessage(message, transfer) serializes message on the sending side and deserializes a fresh copy on the receiving side. The algorithm is structured clone (the HTML Standard's StructuredSerializeWithTransfer); structuredClone() exposes the same one.
What it copies: primitives except Symbol (including BigInt, NaN, -0), plain objects and arrays, Date, RegExp, Map, Set, ArrayBuffer and typed arrays, boxed primitives, Blob, File, ImageData, and Error objects. It keeps cycles and shared references: an array referenced twice arrives as one array referenced twice.
What it loses: an object is copied as its own enumerable string-keyed properties, so a class instance arrives as a plain Object. Methods and prototype getters are gone; an own getter is called and its value copied; symbol keys and non-enumerable properties are dropped. An Error keeps its type only for the built-in names (TypeError, RangeError…); a subclass arrives as Error, without extra properties.
What throws: functions (including methods on a plain object), Symbol values, DOM nodes, WeakMap, promises and proxies throw a DataCloneError DOMException from postMessage() itself, and nothing is sent.
Transfer: objects in the second argument move instead of being copied. Copying a 64 MiB ArrayBuffer blocked the sender for 5.9–10.2 ms in Chrome 156 (15 runs); transferring it took under 0.2 ms. The cost is that the sender's buffer is detached: byteLength becomes 0 and views over it become empty. Transferable types include ArrayBuffer, MessagePort, ReadableStream, ImageBitmap and OffscreenCanvas. A MessagePort or stream must be transferred; putting one in the message without the transfer list throws.
To share memory rather than copy or move it, use SharedArrayBuffer.