Basic JavaScript Question:
Download Questions PDF

What is eval() in JavaScript?


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"));

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?