freecoding.school100% FREE · NO SIGNUP
Await StationISSUE #17 of 26

message channel · structured cloning

PromissaVSRace Condition Rex
Promissa saysMessageChannel creates ports for two-way messaging; structured clone copies complex data.

MessageChannel gives two linked MessagePorts for direct two-way messaging — used with iframes, workers, and postMessage. Messages are copied by the structured clone algorithm (handles objects, arrays, Maps, dates, even cycles — but not functions or DOM nodes). structuredClone(obj) exposes this as a deep-copy utility.

Power-ups you unlock

Race Condition Rex attacks — common mistakes

Boss battleUse structuredClone to deep-copy a nested object and prove they’re independent.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const a={x:{y:1}};const b=structuredClone(a);b.x.y=99;
document.getElementById('o').textContent='a.x.y='+a.x.y+' b.x.y='+b.x.y;</script></body></html>
▶ Open the interactive comic issue
‹ Broadcast Channel · Cross-Tab MessagingLocalStorage · Key-Value Persistence ›