In what ways does the following "eval" regularity break?

Maciej Stachowiak mjs at apple.com
Thu Oct 30 13:32:13 PDT 2008


On Oct 30, 2008, at 1:27 PM, Brendan Eich wrote:

> On Oct 30, 2008, at 1:09 PM, Brendan Eich wrote:
>
>> These bugs involved, e.g. Prototype (the JS library) and its  
>> Ajax.Updater (with evalScripts set to true). The code in question  
>> used Prototype's forEach. A javascript: URL reduction:
>>
>> javascript: (function xxx(){ ["var x"].forEach(eval); })();
>
>
> Prototype 1.5.1.1 (and older, I think we suggested this as a  
> workaround) has
>
>  evalScripts: function() {
>    return this.extractScripts().map(function(script) { return  
> eval(script) });
>  },
>
> No indirect eval called from map, but the operator eval here does  
> not depend on its environment at all (it can't, since neither  
> function in which it nests has any formal parameters or other local  
> bindings). It could be optimized nicely in ES1-3.

Sure, what I am wondering is whether the var declaration you had above  
is expected to be a local or global binding (or if the script doesn't  
care).

Regards,
Maciej



More information about the Es-discuss mailing list