Answer Posted / negi
The eval() function evaluates a string and executes it as if
it was script code.
In this example we use eval() on some strings and see what
it returns:
<script type="text/javascript">
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>
The output of the code above will be:
200
4
27
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is the use of a typedarray object in javascript?
What is npm repository?
What is null in javascript?
What is the data type of variables in javascript?
What is the difference between the operators '==' and '==='?
What is differential inheritance?
What is a frontend framework?
What is s+ in regex?
What is the difference between write and writeln in javascript?
Are namespaces are there in javascript?
What are the methods involved in javascript?
How to force a page to go to another page using javascript ?
How does javascript work?
How do I view javascript in chrome?
What are JavaScript Cookies?