The eval() function evaluates a string and executes it as if it was script code.
Syntax
eval(string)
Parameter: string Required.
Description: The string to be evaluated
Example
In this example we use eval() on some strings and see what it returns:
200
4
27
Final code and demo is here
Demo
Syntax
eval(string)
Parameter: string Required.
Description: The string to be evaluated
Example
In this example we use eval() on some strings and see what it returns:
<script type="text/javascript">The output of the code above will be:
eval("x=10;y=20;document.write(x*y)");
document.write("<br />");
document.write(eval("2+2"))
document.write("<br />");
var x=10
document.write(eval(x+17))
document.write("<br />")
</script>
200
4
27
Final code and demo is here
Demo
No comments:
Post a Comment