> I was challenging Axel's characterization of how JS devs use typeof, since it > leads him to conclude that we need to add a bunch of new language features. > In code I see, devs don't use typeof for checking a value is null or > undefined, so don't base new language features on this use case.
My intention was to list all use cases, to see where typeof could possibly be useful (i.e., to assert its merits). Should it be better to replace it with something else, then there might not be a need to fix typeof null. > I agree that the common practice of testing if(!name) has pitfalls. But > doesn't the common practice suggest that more elaborate features will not > help? We need something as simple as if (!name). Default parameter values should mostly take care of this. The default operator also looks useful (if extended to include null): http://wiki.ecmascript.org/doku.php?id=strawman:default_operator It might make sense to add ?? as a unary operator: var myvar; console.log(?? myvar); // false console.log(?? globalUnknown); // false var obj = {}; console.log(?? obj.prop); // false If something non-grawlixy is preferred, one could give it a name such as `exists`. Furthermore, it might be more consistent with value ?? default to make ?? a postfix operator, but I can’t judge the grammatical implications of that. -- Dr. Axel Rauschmayer [email protected] home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

