arguments.callee in Harmony

Charles Jolley charles at sproutit.com
Fri Sep 25 14:42:19 PDT 2009


>
>> ClassB = ClassA.extend({
>> foo: function method() {
>>   (IS_ES5_STRICT ? method : arguments.callee).base.apply(this,  
>> arguments);
>> }
>> });
>
> But why wouldn't you use method always? Or callee, as Ollie  
> suggested. Agree it's annoying to have to add six letters of cruft  
> after the function keyword (with space separator) but once you do  
> that, provided you dodge IE bugs, why do you need arguments.callee  
> at all?

Precisely to avoid IE bugs.  So maybe it will be written more like:

foo: function callee() {
   (SC.HAS_IEBUG ? arguments.callee : callee).base.apply(this,  
arguments);
}

where SC.HAS_IEBUG is true if IE version <= [last version of IE with  
named-method bug]

>> PS. Is there an official way to detect that I am running code in  
>> ES5 strict mode?  I can't find it in the spec.
>
> if (! function () {return this;}()) { /* in strict mode */ }
>
> is IIRC a shorter way, relying on falsy-ness of undefined, to test.

Cool!  Thanks.

Has anyone considered providing a more explicit way of testing for  
this?  Maybe a constant that is defined somewhere.  Anyway, that's  
what I'm going to do:

SC.HAS_STRICT = !(function() { return this;}());

:)

> /be
>



More information about the es-discuss mailing list