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