Cross-global instanceof

Brandon Benvie bbenvie at mozilla.com
Thu Oct 31 09:43:21 PDT 2013


On 10/31/2013 8:50 AM, David Bruant wrote:
> I'm not sure it's worth making it work for jQuery. This is trying to 
> make a good use of same-origin multi-global which shouldn't exist in 
> the first place. Keeping same-origin access as it is and encouraging 
> people to add @sandbox even on same-origin iframes seems like a better 
> idea.
>
> Should the addition be a nicer Object.prototype.toString.call?

You're right, it's not instanceof. But I definitely think the argument 
can be made that there is a need for checking if something is of a 
certain class. I'm finding myself wanting things like `isGenerator` and 
`isGeneratorFunction`, for example. There's countless examples of people 
re-purposing Object.prototype.toString to serve this functionality ad hoc.


More information about the es-discuss mailing list