typeof symbol (Was: Sept 19 TC39 Meeting Notes)

Brendan Eich brendan at mozilla.org
Sat Sep 29 16:12:32 PDT 2012


You may have missed the 1JS and typeof null messages. We cannot remove "function" or make any other such backward-incompatible change. But we could add new results.

The problem with instanceof is that it fails cross frame.

The invariant two-way implication relating == and === that I gave is important, and for value objects such as int64 and uint64 I argue it implies new typeof results.

/be

On Sep 29, 2012, at 3:46 PM, "Uli Riehm" <uli.riehm at metadea.de> wrote:

> I think typeof should be simplified, focusing more on instanceof: typeof should only return "undefined", "string", "number", "boolean" and "object".
> 
> var fn = function () { };
> fn instanceof Function // true
> fn instanceof Object // true
> 
> Because typeof returns a string it is never true for two different types, so instanceof is more detailed. Problems would be that Null, NotANumber, Infinity habe to be functions, so that a null can also be instanceof an Object and a NaN instanceof NotANumber Number Object. Using an Int64 Function where the prototype is Number, we could also have an instanceof Int64 Number Object.
> 
> I'm also tweaking around instanceof in my article on http://metadea.de/V/default.aspx#V_construct_and_your_class ... please see how I'm creating 'class' functions, having real OOP in jS, using instanceof, featuring reflection using a V.Construction Object class info (that is also used for prototyping a base function) and an the implicit instanceOf and constructionOf functions. Without hacking around __proto__ .
> 
> However I'd like to say that in the part of "Why javaScript typeof operator should be deprecated" I didn't thought properly about primitives and the usage of the operators that my idea would completely break ;) So please read that part with this warning in mind, but there are also some thoughts on primitives that are boxed to Object.
> To say simple what I need to change in the ...deprecated... part is, that typeof and primitives should keep, but the constructor and the primitives corresponding Object instances should be the way described.
> 
> Uli 
> 


More information about the es-discuss mailing list