Ye olde arguments argument (was: Topic list - pending changes and issues for the ES3.1 spec)

Tobie Langel tobie.langel at
Fri Sep 12 15:54:48 PDT 2008

On Sep 11, 2008, at 14:34 , Brendan Eich wrote:

> I snipped your words about callee, but it's used quite a bit in Ajax
> libraries, e.g, Prototype:
> $ grep -w callee prottype.js
>      replacement = arguments.callee.prepareReplacement(replacement);
>      var self = arguments.callee;
>      parts.add = arguments.callee.addPair;
> (Prototype

In Prototype, arguments.callee is used in two distinct cases:

1) reading a property of the callee, and
2) recursively calling the callee.

Case #1 is easily solved by storing the said property in a closure,  
or by setting it elsewhere (where it probably would be a better fit,  

Case #2 is easily solved by using a named function instead. For the  
particular case where it is used in Prototype, the anonymous function  
lies inside of a closure, so there is no chance of triggering the  
JScript scope bug nor of polluting the global namespace when naming it.

 From what I understand, ES 3.1 strict mode compliance will be opt-in  
and will require at least slight source code modifications (if only  
to prepend it with the 'use strict'; expression). So current versions  
of Prototype (or other libs, for that matter), will not be ES 3.1  
'strict' compliant by default.

I'm not really worried about modifying Prototype to avoid use of the  
arguments.callee property. As a matter of fact, we've already done so  
in a development branch for Caja compliance.

Note that jQuery does not use arguments.callee at all.



More information about the Es-discuss mailing list