arguments.callee in Harmony

Brendan Eich brendan at mozilla.com
Fri Sep 25 16:15:47 PDT 2009


On Sep 25, 2009, at 4:07 PM, Charles Jolley wrote:

> I would think the most useful test would be "is strict mode  
> available" not "am I currently strict" since you can assume the  
> later from the former but not the reverse.

Not sure how you can assume the latter from the former:

if (! function() { "use strict"; return this; }()) {
   /* I'm in an ES5-supporting browser, but strict is not necessarily  
enabled here */
}

Again strict is a static property of code, so if there were a "use  
strict" above the if, even if there were functions nesting around the  
if, so long as the global code or one of the surrounding functions had  
a "use strict" pragma, we'd be in strict mode in the commented "then"  
clause.

But if not, then the "use strict" in the lambda in the if's condition  
doesn't cause any change to what follows the condition.


> I suppose we could always just use browser sniffing. ;-)

The idioms are better but you have a point :-P.

/be


More information about the es-discuss mailing list