<script>
var the_unevaled_answer = "2 + 3";
var the_evaled_answer = eval("2 + 3");
alert("the un-evaled answer is " + the_unevaled_answer + " and the evaled answer is " + the_evaled_answer);
</script>
eval会求出表达式内的值来。
如果换成2+3+a,则不执行。
<script>
var the_unevaled_answer = "2 + 3";
var the_evaled_answer = eval("2 + 3");
alert("the un-evaled answer is " + the_unevaled_answer + " and the evaled answer is " + the_evaled_answer);
</script>
eval会求出表达式内的值来。
如果换成2+3+a,则不执行。