arguments.callee in Harmony

Garrett Smith dhtmlkitchen at gmail.com
Sat Jan 9 20:53:01 PST 2010


On Fri, Sep 25, 2009 at 1:42 PM, Charles Jolley <charles at sproutit.com> wrote:
>>
>>> 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]
>


That does not avoid jscript bug with named function expressions; it
triggers it.

That is not "the only way" to implement inheritance. It apparently
relies on a `base` property of the function object. That is not part
of ECMAScript. What is it?

I suggest avoiding super calls. If you really must, then consider a
standard approach that will work consistently across browsers, and in
ES3 and ES5 strict:

ClassB.prototype = {
  foo: function() {
    ClassA.prototype.foo.call(this);
  }
};

[snip]

Garrett


More information about the es-discuss mailing list