原文:https://github.com/yangshun/front-end-interview-handbook/blob/master/questions/javascript-questions.md 最近将持续翻译JavaScript面试题,希望对各位有所帮助. (文章中斜体字部分为译者添加) 目录: Part 1(事件委托/this关键字/原型链/AMD与CommonJS/自执行函数) Part 2 (null与undefined/闭包/foreach与map/匿名函数/代码组织)…
匿名函数中(function(){}).call(this) 中的.call(this) 有什么用? 我们都知道,.call()可以改变函数执行时的context,即this的指向,源码中的.call(this) 主要就是,把当前的context传递给匿名函数. So, if for whatever reason you use this, it's a way to make the IIFE act as if it were a member function of Foo, speci…