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
Why it is not advised to use innerhtml in javascript?
Explain how to write class methods vs. Instance methods.
What is the difference between window and document in Javascript?
What does the delete operator do?
What are all the types of Pop up boxes available in JavaScript?
How to convert javascript date to iso standard?
What's the date object using javascript?
What is the difference between local storage & session storage?
What will happen if an infinite while loop is run in Javascript?
What is the difference between remove() and removeChild()?
What are the requirements of web application using javascript?
What is the reason for wrapping the entire content of a javascript source file in a function book?
What is enum in javascript?
What are the decodeURI() and encodeURI()?
What is Currying in Javascript?