Eval
From PlainOldWebserver
eval()
There should be more interesting things to do in eval, but here is a contrived example. What if you wanted to use eval to save an old value, but not affect the same global variable when it is used. Here we create an anonymous function and run it.
<?sjs
var a = 5;
var fun = "(function dog(a) { a++; document.writeln('a is '+a); }("+a+"))";
eval("a++; document.writeln('a is '+a);");
eval("a++; document.writeln('a is '+a);");
eval(fun);
eval("a++; document.writeln('a is '+a);");
?>
Result:
a is 6 a is 7 a is 6 a is 8
