typeof null

Axel Rauschmayer axel at rauschma.de
Tue May 8 10:09:41 PDT 2012


typeof is so quirky that I’m not sure fixing it is worth the trouble. It might make more sense to introduce a new mechanism that subsumes both typeof and instanceof and also took value objects into consideration (if there is a use case for doing so). Additionally, using typeof for finding out whether a variable is declared or not seems like a separate concern to me. If that was handled via a separate operator then one could prototype improved versions of typeof via libraries (because typeof unknownVariable not throwing is something you can’t implement via a library).

Axel

On May 8, 2012, at 18:19 , Rick Waldron wrote:

> Aware that that typeof null has been rejected, but I was wondering if it could be revived via the implicit "opt-in" path, eg:
> 
> non-strict, non-opt-in:
> 
> typeof null === "null"; // false
> 
> implied opt-in:
> 
> module Foo {
>   export function create( options ) {
> 
>     if ( typeof options === "null" ) {
>       return ... some default thing;
>     }
>   };
> }
> 
> import create from Foo;
> 
> let default = create( null );
> 
> 
> Is something like this even possible?
> 
> Rick
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120508/dc0b87f0/attachment.html>


More information about the es-discuss mailing list