It's pretty simple: Strict mode doesn't forbid eval, it just disables the dynamic scoping of eval:
var x;
function y(k) {
eval(k);
x = 4; //Under strict mode, this always references the outer x
}
Domanda
JavaScript strict mode forbids usage of the eval function. However, I don't see how dynamic code loading/generation can be implemented without it. Are there any new APIs for this? What are the alternatives?
Soluzione
It's pretty simple: Strict mode doesn't forbid eval, it just disables the dynamic scoping of eval:
var x;
function y(k) {
eval(k);
x = 4; //Under strict mode, this always references the outer x
}