arguments.callee in Harmony

Brendan Eich brendan at mozilla.com
Fri Sep 25 15:58:54 PDT 2009


On Sep 25, 2009, at 3:35 PM, Brendan Eich wrote:

>> Otherwise, what you're testing for is something like "is this code  
>> currently running in strict mode" or "was this library loaded under  
>> strict mode"?
>
> Thanks for wiping up after me. :-)

David kindly pointed out that what I suggested originally is also  
useful, and possibly it was what Charles wanted:

if (! function() { return this; }()) {
     /* this if statement is in strict code */
}

is useful in its own right. The other test is also useful:

if (! function() { "use strict"; return this; }()) {
     /* we're loaded in a browser supporting ES5 */
}

These are certainly idioms, especially the first test (as in "kick the  
bucket", something an ES3 programmer could not understand based on the  
terms in the code alone, only by also reading the ES5 spec or a book  
based on it). Do they deserve sugar?

/be


More information about the es-discuss mailing list