typeof symbol (Was: Sept 19 TC39 Meeting Notes)

Brendan Eich brendan at mozilla.com
Mon Oct 1 16:05:51 PDT 2012

Axel Rauschmayer wrote:
> Right, sorry for conflating two issues. My main point was: any kind of 
> simplification of the current situation helps (even typeof o === 
> "null" which, OTOH, might not be worth the risk).

We can't change typeof null === "null". V8 tried and it broke the web, 
and 1JS means we do not want typeof changing rules under module {...} -- 
that's a gratuitous refactoring hazard.

typeof (function(){}) == "function" && typeof null == "object" && typeof 
{} == "object" -- just grieve and accept! I have :-P. Doesn't mean 
typeof is not useful and indeed widely used, and important for the 
==/=== two-way implication. Other type tests would work for that 
implication, but typeof is the one in the language.

> Regarding cross-frame: Many explanations on the web of determining 
> whether a value is an array sound like this is an impossible task 
> (ignoring Array.isArray()) and that’s a shame. Alas, I’m not sure how 
> one could do better here, it’s really a tricky problem. postMessage 
> seems like a partial solution.

Or Object.prototype.toString.call(x).slice(8, -1) === "Array"? Not 
iron-clad but prior to Array.isArray, nothing is.


More information about the es-discuss mailing list