
What is eval() in JavaScript?

In JavaScript, eval is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated (all statements are expressions in both Javascript & ActionScript), and allows the final semicolon to be left off.
Example as a statement executor:
<head>
<script type="text/javascript">
fo = 2;
eval('fo = fo + 2;alert(fo);');
</script>
</head>
<body onload="eval()">
</body>
Example as an expression evaluator:
<head>
<script type="text/javascript">
fo = 2;
alert(eval('fo + 2'));
</script>
</head>
<body onload="eval()">
</body>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.