https://www.runoob.com/js/js-strict.html
https://wenku.baidu.com/view/4801248968dc5022aaea998fcc22bcd127ff4265.html
https://www.cnblogs.com/niejunchan/p/6359103.html
https://www.cnblogs.com/JoannaQ/p/3424601.html
https://www.cnblogs.com/wjaaron/p/8280373.html
http://www.ruanyifeng.com/blog/2013/01/javascript_strict_mode.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript中严格模式strict mode</title>
<script type="text/javascript">
//"use strict" 指令只允许出现在脚本或函数的开头
//注意:大家测试严格模式的时候,"use strict";必须放在脚本的第一行,否则就不是严格模式
//"use strict";必须放在脚本的第一行,否则就不是严格模式,而是正常模式
/*
将”use strict”放在脚本文件的第一行,则整个脚本都将以”严格模式”运行。如
果这行语句不在第一行,则无效,整个脚本以”正常模式”运行。
*/
/*
如下这种情况,没有把"use strict";这句话放在脚本的第一行,所以此时是正常模式,而不
是严格模式,就算后面写了"use strict";这句话,也不是严格模式了,所以,"use strict";必
须放在脚本的第一行。
*/
// var userName = 'jack';
// "use strict";
// hometown = '江西省赣州市于都县';
// console.log(hometown);
// "use strict";
// address = '于都县';
// console.log(address);
// "use strict";
//报错(salary未定义)
// salary = 18500.67; // Uncaught ReferenceError: salary is not defined
// "use strict";
// fn1();
// function fn1() {
// age = 14; //Uncaught ReferenceError: age is not defined
// }
//在函数内部声明是局部作用域 (只在函数内使用严格模式):
// a = 888; // 不报错
// console.log(a); //结果为888
// fn2();
// function fn2() {
// "use strict";
// b = 666; // 报错Uncaught ReferenceError: b is not defined
// }
// c = 123; // 不报错
// console.log(c); //结果为123
// fn3();
// function fn3() {
// "use strict";
// c = 657; // 不报错
// console.log(c); //结果为657
// var c = 168;
// console.log(c); //结果为168
// }
// "use strict";
//不允许使用未声明的变量
// f = 3.22; //Uncaught ReferenceError: f is not defined
// "use strict";
//对象也是一个变量
// d = {num1:16, num2:23}; //Uncaught ReferenceError: d is not defined
// "use strict";
// var e = 3.14;
//不允许删除变量或对象。
// delete e; //Uncaught SyntaxError: Delete of an unqualified identifier in strict mode
// "use strict";
// function fn4(p1, p2) {};
//不允许删除函数
// delete fn4;//Uncaught SyntaxError: Delete of an unqualified identifier in strict mode
"use strict";
//不允许变量重名
//报错Uncaught SyntaxError: Duplicate parameter name not allowed in this context
function fn5(p1, p1) {};
//下面的情况我就没有举例了,参考网页https://www.runoob.com/js/js-strict.html
//不允许使用八进制
//不允许使用转义字符:
//不允许对只读属性赋值:
//不允许对一个使用getter方法读取的属性进行赋值
//不允许删除一个不允许删除的属性:
//变量名不能使用 "eval" 字符串:
//变量名不能使用 "arguments" 字符串:
//不允许使用以下这种语句:
//由于一些安全原因,在作用域 eval() 创建的变量不能被调用:
//禁止this关键字指向全局对象。
</script>
</head>
<body style="background-color: #CCE8CF;">
<h3 style="color: #cd1636;">
JavaScript中严格模式strict mode
</h3>
JavaScript 严格模式(strict mode)即在严格的条件下运行
<br/>
use strict的目的是指定代码在严格条件下执行。
<br/>
严格模式下你不能使用未声明的变量。
<br/>
支持严格模式的浏览器:Internet Explorer 10 +、
Firefox 4+ Chrome 13+、 Safari 5.1+、 Opera 12+。
<br/>
<a href="https://www.runoob.com/js/js-strict.html" target="_blank">
JavaScript严格模式(use strict)参考网页https://www.runoob.com/js/js-strict.html
</a>
<br/>
<a href="https://www.runoob.com/js/js-hoisting.html" target="_blank">
JavaScript变量提升参考网页https://www.runoob.com/js/js-hoisting.html
</a>
<br/>
<a href="https://blog.csdn.net/czh500/article/details/103455845" target="_blank">
javascript变量提升详解参考网页https://blog.csdn.net/czh500/article/details/103455845
</a>
</body>
</html>