typeof symbol (Was: Sept 19 TC39 Meeting Notes)

Brendan Eich brendan at mozilla.org
Sat Sep 29 11:56:26 PDT 2012

Axel Rauschmayer wrote:
>> I agree with Tom, "object" is the best choice if we are to avoid 
>> extending typeof's codomain. If we choose to extend, then your best 
>> case made above arguess for "symbol", not "string".
> I’ve been wondering: instead of fixing typeof, wouldn’t it be simpler 
> to extend instanceof, by introducing new types:
> - ReferenceType: to check whether a value is an object. Currently, 
> objects such as Object.create(null) and Object.prototype are objects 
> that are not instanceof Object.

This doesn't work with value objects, and anyway doesn't work by testing 
proto-chain membership starting from RHS.prototype where RHS is the 
constructor function.

> - ValueType: for primitives and possibly future value objects.
>     - PrimitiveBoolean: for primitive booleans, same as typeof x === 
> 'boolean'

Again, we cannot inserte more prototypes on existing proto-chains.

>     - etc.
> Should there ever be guards in the future, instanceof MyGuard would 
> also make sense.
If you are not using the proto-chain, then what? What's the underlying 
theory for extending instanceof?

Compatibility concerns make this a non-starter, IMHO. We'd do better to 
keep instanceof simple and extend typeof. IE already has extra typeof 
results so developers have to beware.


More information about the es-discuss mailing list