xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript 函数级严格模式use strict 示例 - 基础教程(div.cn)</title>
<body>
<h1>"use strict";</h1>
<p>要在浏览器中访问调试,请按F12,然后在调试器菜单中选择"控制台":</p>
<script>
document.write(myFunc());
function myFunc() {
// 函数级严格模式语法
"use strict";
str = "Hi I'm a strict mode function!"; // 这将导致一个错误,因为没有定义str
return str;
}
</script>
</body>
</html>