//js使用严格模式可以规范我们写代码

//要启用严格模式,您只需要在 JavaScript 脚本的开头添加"use strict";或'use strict';指令即可,如下所示:
<script>
    "use strict";
     x = 'http://c.binacheng.net/'; // 此处报错:Uncaught ReferenceError: x is not defined at index.html:11
  console.log(x);
</script>

//如果将"use strict";指令添加到 JavaScript 程序的第一行,则表示整个脚本都会处于严格模式。如果在函数的第一行代码中添加"use strict";,则表示只在该函数中启用严格模式。/如下例所示:
<script>
    x = 'http://c.binacheng.net/';
    console.log(x);

    function sayHello(){
        'use strict';
        str = 'welcome http://c.binacheng.net/'; // 调用 sayHello() 函数在此处报错:Uncaught ReferenceError: str is not defined at sayHello (index.html:14) at index.html:17
        console.log(str);
    }
    sayHello();
</script>