Basic JavaScript Question:

What is eval() in JavaScript?

Tweet Share WhatsApp

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 PDF Read All 114 JavaScript Questions
Previous QuestionNext Question
How to associate functions with objects using JavaScript? What does break and continue statements do in JavaScript?