What is the use of eval() in javascript ?

 Posted by Bharathi Cherukuri on 7/11/2012 | Category: JavaScript Interview questions | Views: 1809 | Points: 40
Answer:

The eval() method is allows you to execute code snippets during execution.

Example:

<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


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response