概念

es5.0 严格模式是指 es3.0 和 es5.0 产生冲突发部分就是用 es5.0,否则就用 es3.0

ES5.0启动 “use strict”,使用字符串形式启动,不会对不兼容严格模式的浏览器产生影响

  1. 'use strict' //不管是在全局还是在函数里,必须写在最顶端,推荐写在局部
  2. function test() {
  3. console.log(arguments.callee)
  4. }
  5. test()
  6. //TypeError: 'caller', 'callee', and 'arguments' properties may not be
  7. accessed on strict mode functions or the arguments objects for calls to the

特性

不支持 with
with()括号里面的代码会按照正常顺序执行,但是如果在括号里面添加了对象,就 会把对象当做 with 要执行的代码体的作用域链的最顶端(最直接的最近的 AO)。
image.png

arguments.callee,function.caller 不能用
image.pngimage.png

变量赋值前必须声明
image.png

局部 this 必须被赋值(Person.call(null/undefined) 赋值什么就是什么)
image.png
image.png

函数不能有重复的参数,对象不能有重复的属性
image.png
image.png

eval
eval 很强大,能把字符串当成代码来执行
但是约定俗成在 es3.0 中都不能使用 eval。eval 是魔鬼,因为会改变作用域