I would like to check if an object is an instanceof a certain built-in class. The problem is that my checking code might not be in the window where the object is defined, so x instanceof String would return false even though x is a String. What I need is something like x instanceof getWindowOf(x)['String']? But is it possible to define a function such as getWindowOf?
Or, we could solve this in another way if we were able to get all the windows of a JS application. top, and looping recursively through top.frames come close, but we would be missing pop-ups.
So what's a solution?
Note that I am just using String as an example. I really want to check classes like Element or any other classes defined in the browser.