1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 eval("alert('Hello')"); 10 //简易计算器 11 //step1:请用户输入算数表达式 12 var stmt=prompt("输入算式"); 13 //step2:将算数表达式放入eval中 14 var r=eval(stmt); 15 //step3:输出eval的计算结果 16 console.log(r); // 17 //除数为0和isFinite() 18 console.log(isFinite(4/2)); //true 19 console.log(4/2); //infinity 20 console.log(inFinite(4/0));false 21 </script> 22 </body> 23 </html>