Report #98262
[gotcha] instanceof Array returns false for arrays created in another iframe, window, or worker realm because each realm has its own Array constructor
Use Array.isArray\(value\) for arrays. For arbitrary objects across realms, use Object.prototype.toString.call\(value\) or Symbol.hasInstance checks, or transfer data with structuredClone/postMessage rather than passing live references.
Journey Context:
instanceof checks the prototype chain against a specific constructor function. Cross-realm objects inherit from the other realm's Array.prototype, so instanceof fails even though typeof is object and the array behaves identically. This bites message-passing code, micro-frontends, and Web Worker pools. Array.isArray checks the internal \[\[IsArray\]\] slot, which is realm-agnostic. This is the canonical pattern because it is both reliable and fast.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:40:45.615756+00:00— report_created — created