Re: double checking if window.eval(…) is an indirect call to eval().

John-David Dalton john.david.dalton at gmail.com
Sat Aug 27 12:53:29 PDT 2011


> No. It's the global object what is the base (more precisely, its DOM's proxy wrapper -- `window` or either the global itself), but not an environment record.

So basically the only kind of MemberExpression allowed is a PrimaryExpression?

So writing it out is like:
  http://es5.github.com/#x8.7.1
  `window.eval`  -> GetValue(`window.eval`) -> `window` is seen as the
base so it
  goes to step 4 of 8.7.1 and not step 5 (which is for environment records).

ES3 makes it a bit more clear:
"If value of the eval property is used in any way other than a direct
call (that is, other than by the
explicit use of its name as an Identifier which is the
MemberExpression in a CallExpression), or if the
eval property is assigned to, an EvalError exception may be thrown."

Though older browsers w/ their older implementations will barf on `(1,
eval)(…)` but not `window.eval(..)` for some reason.

> No, it's indirect.
>
> http://dmitrysoshnikov.com/ecmascript/es5-chapter-2-strict-mode/#indirect-eval-call

I knew you would chime in with a link to your post, which is why I
wrote I read the notes associated with the link I posted (your post
was one of the notes) :P

- JDD


More information about the es-discuss mailing list