JavaScript eval() 函数

<html>
<body>

<script type="text/javascript">

eval("x=10;y=20;document.write(x*y)")
document.write("<br />")

document.write(eval("2+2"))
document.write("<br />")

var x=10
document.write(eval(x+17))
document.write("<br />")

eval("alert('Hello world')")

</script>

</body>
</html>
 
 
效果:
 

 

原文地址:https://www.cnblogs.com/ChenChunChang/p/8302578.html