摘要: 严格模式下,匿名函数内部的 this 不再是 window,而是undefined "use strict"; (function(){ console.log(this); })(); 输出 undefined 使用 bind 方法修正 "use strict"; (function(){ con 阅读全文
posted @ 2020-02-28 20:27 内心澎湃的水晶侠 阅读(108) 评论(0) 推荐(0) 编辑
摘要: JS 中 方法里的变量声名提前 如下的一段代码,虽然在匿名方法中可以访问全局变量 global, 但由于声明被提前,所以输出依然是undefined var global = 3; (function(){ console.log(global); var global = 5; })(); 等价代 阅读全文
posted @ 2020-02-28 20:22 内心澎湃的水晶侠 阅读(122) 评论(0) 推荐(0) 编辑