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@...
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss