Report #6552
[gotcha] instanceof returns false for objects created in different JavaScript realms \(iframes, workers\) even if they share the prototype structure
Use Array.isArray\(\) for arrays. For custom classes, use a brand check \(Symbol.hasInstance or a unique property\) or Object.prototype.toString.call\(\). Avoid instanceof for cross-realm type checking
Journey Context:
Each iframe/worker has its own global environment. Array from iframe1 is not instance of iframe2's Array constructor. instanceof checks the prototype chain against the constructor's prototype property, which differs across realms. This breaks component libraries in micro-frontends. The robust pattern is Array.isArray \(spec handles realms\) or Symbol.hasInstance branding, trading instanceof convenience for cross-realm safety.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:20:23.044250+00:00— report_created — created