arguments.callee and strict mode

Allen Wirfs-Brock Allen.Wirfs-Brock at
Tue Mar 10 09:33:57 PDT 2009

Good point about, POLA.  Of course, arguments.callee is writable (and deletable)  so it could be removed or modified before passing it on.

POLA is also the reason for preferring use of the Function constructor over eval. The function constructor is essentially a constrained eval that carries less authority.  In particular, in non-strict mode eval can create bindings in the Declaration Environment of its caller (or the Global Environment) and in either mode it can modify any in scope bindings.  More generally, eval can execute arbitrary code and have arbitrary side-effects. None of that applies to calling the Function constructor.  Those seem like really good reasons to encourage use of the Function constructor instead of eval, where possible.


From: Mark S. Miller [mailto:erights at]
Sent: Tuesday, March 10, 2009 9:03 AM
To: Allen Wirfs-Brock
Cc: Douglas Crockford; David-Sarah Hopwood; es-discuss at
Subject: Re: arguments.callee and strict mode

On Tue, Mar 10, 2009 at 8:52 AM, Allen Wirfs-Brock <Allen.Wirfs-Brock at<mailto:Allen.Wirfs-Brock at>> wrote:

In reviewing the spec. I was reminded that arguments.callee is disabled within strict mode functions.  Do you recall why you wanted to do this, other than general dislike of arguments.
POLA. A frequent and sensible pattern of use for "arguments" is to pass it along to someone else to give them access to your arguments list. In typical usage, it is not usually intended or desired to thereby give them access to the function itself, not to give them the ability to alter your parameter variables (hence the lack of joining).

It occurs to me, that using arguments.callee is the only way  to express recursion within a function created using the Function constructor and that use of the Function constructor (rather than eval) should probably be encouraged for dynamically constructing functions from source code.
Why? I was thinking exactly the opposite: That we should encourage use of eval() rather than the Function constructor for dynamic creation of functions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Es-discuss mailing list