Basic JavaScript Question:

Download Job Interview Questions and Answers PDF

What is eval() in JavaScript?

JavaScript Interview Question
JavaScript Interview Question

Answer:

The eval() method is incredibly powerful allowing us to execute snippets of code during execution in JavaScript.

<script type="text/javascript">
var USA_Texas_Austin = "521,289";
document.write("Population is "+eval("USA_"+"Texas_"+"Austin"));
</script>

This produces
Population is 521,289

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
How to associate functions with objects using JavaScript? What does break and continue statements do in JavaScript?