表达式计算 如 
   var i=0;
   i=i+1;
   alert(i);
 和
   var i=0;
   eval("i=i+1;");
   alert(i);  结果相同!  我的理解是 eval 就是一个脚本引擎!

解决方案 »

  1.   

    简单的来说,就是执行字符串形式的表达式
    例如
    s="alert('OOOOOOOOOOOOOOOK')";
    eval(s);相当于执行了 alert('OOOOOOOOOOOOOOOK')
      

  2.   

    语法
    eval(codestring) 
    codestring 参数是包含有效 JScript 代码的 String 对象. 这个字符串将由 JScript 分析器进行分析和执行. 说明
    eval 函数允许 JScript 源代码的动态执行. 例如,下面的代码创建了一个包含 Date 对象的新变量 mydate : 
    eval("var mydate = new Date();");
    传递给 eval 方法的代码执行时的上下文和调用 eval 方法的一样.
      

  3.   

    Description
    Evaluates JScript code. 
    Syntax
    eval(codestring) 
    The codestring argument is a String object that contains valid JScript code. This string is parsed by the JScript parser and executed. Res
    The eval function allows dynamic execution of JScript source code. For example, the following code creates a new variable mydate that contains a Date object: 
    eval("var mydate = new Date();");
    The code passed to the eval method is executed in the same context as the call to the eval method.
      

  4.   

    Description
    Evaluates JScript code. 
    Syntax
    eval(codestring) 
    The codestring argument is a String object that contains valid JScript code. This string is parsed by the JScript parser and executed. Res
    The eval function allows dynamic execution of JScript source code. For example, the following code creates a new variable mydate that contains a Date object: 
    eval("var mydate = new Date();");
    The code passed to the eval method is executed in the same context as the call to the eval method.