Skip to content

JavaScript中的this

LYF edited this page Mar 7, 2016 · 1 revision
  1. this跟代码中的位置没有关系,是在执行时赋值的。也就是说this只存在于函数调用(运行)期间,在变量作用域中不存在

    • 分析this时,不能看代码位置来确定,要看怎么调用的

    • this是在函数运行期赋值的,这步由JavaScript引擎来做,if(!this && !strictFlag) { this = window}

  2. this是不会沿着变量作用域、原型链或闭包结构向上查找的

Clone this wiki locally