eval() : eval « Global « JavaScript Tutorial






Syntax

eval(command)
    eval(string)

The eval() function accepts a string of JavaScript statements and evaluates it as JavaScript source code.

eval() returns the value of the executed JavaScript statement.

<html>
    <body>
    <script lanuguage="JavaScript">

    <!--
    function run(){
         eval (document.form1.input1.value);
    }
    -->

    </script>
    <form name="form1">
    Enter a JavaScript command in the text field and click the "execute" button to execute the command.
    <br><br>
    Command:<input type="text" name="input1" size=30>
    <br>
    <input type="button" value="execute" onClick='run()'>
    </form>
    </body>
    </html>








8.3.eval
8.3.1.eval()