On Twitter, Allen Wirfs-Brock asked folks if they knew what
Array.isArray(obj) did, and the results suggested… no they don't. For what it's worth, I also got the answer wrong.
Let's say we wanted to do something specific if
obj is an array.
JSON.stringify is an example of this, it outputs arrays differently to other objects.
We could do:
But that's false for things that extend arrays:
If you want to catch subclasses, there's
But things get more complicated when you introduce multiple realms:
... read the whole story at jakearchibald.com.
self refers to. So, it can be said that code running in a worker is in a different realm to code running in the page. The same is true between iframes, but same-origin iframes also share an ECMAScript 'agent', meaning objects can… (and please read the next bit in a 70s sci-fi voiceover)