ES5 严格模式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37722811/article/details/84430022

"use strict"

1. 不再兼容ES3的一些不规则语法,使用全新的ES5规范

2. 两种用法:

      全局严格模式

      局部函数内严格模式(推荐)

就是一行字符串,不会对不兼容严格模式的浏览器产生影响

不支持with,arguments.callee,func.caller,变量赋值前必须声明,局部this必须被赋值(Person.call(null/undefined) 赋值什么就是什么),拒绝重复属性和参数。

3. 严格模式对局部this的影响

this绑定规则 非严格模式 严格模式
默认绑定 window undefined
显示绑定

null -->window

undefined-->window

原始值-->包装对象

null

undefined

原始值

     

猜你喜欢

转载自blog.csdn.net/m0_37722811/article/details/84430022