What is the eval() function?

Q

What is the eval() function?

✍: Guest

A

The eval() method is incredibly powerful allowing you to execute snippets of code during exection.

<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

2011-08-09, 3725👍, 0💬