源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>"use strict" 在函数中只会引起该函数的错误.</p> <p>激活你的浏览器调试(F12)查看错误报告.</p> <script> x = 3.14; // This will not cause an error. myFunction(); function myFunction() { "use strict"; y = 3.14; // This will cause an error (y is not defined). } </script> </body> </html>
运行结果