源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <h1>使用"use strict":</h1> <h3>不允许使用对象而不声明.</h3> <p>激活你的浏览器调试(F12)查看错误报告.</p> <script> "use strict"; x = {p1:10, p2:20}; // This will cause an error (x is not defined). </script> </body> </html>
运行结果