<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <script>
//1.eval 计算字符串的值// var str="12-2";// var str1="56*2-12+3"// alert(eval(str1))
//2.还可以进行转换// var str=[2,3,4,5]// alert(eval(str[2]))
//3.还可以转换js代码 var str="function show(){alert('123')}"; eval(str); show()
</script></head><body>
</body></html>
转载于:https://www.cnblogs.com/mylove0/p/7481521.html