Strict undefined this

Douglas Crockford douglas at crockford.com
Fri Aug 29 19:44:27 PDT 2008


Mark S. Miller wrote:

> Therefore, I'd prefer either #b or #c to #a. Between #b and #c I don't
> have a strong preference, but I think I prefer #b (it's safer) to #c
> (it more clearly preserves Tennent Correspondence and is generally
> easier to reason about). But I'd be happy with either.
> 
> This question needs to be settled for the ES3.1 spec, and so has a
> greater urgency than many of our other recent discussions.

I share your discomfort with #a. I prefer #c because it gives the developer the 
option to do stuff like

     if (this === undefined) {
         throw "Did you forgot to use the new operator when calling F?";
     }

That would allow a library developer to provide more useful diagnostic messages. 
That is a low-value advantage, but I think it does break the tie. I don't see #b 
being any safer.


More information about the Es-discuss mailing list