this — Javascript基础探究篇(8)

this 应该是js中最为复杂的机制之一。搞懂 this 某种程度上意味着一次重生。 我们先通过一段代码来看看 this 有多么让人琢磨不透: function foo(num) { console.log(`foo: ${num}`); this.count++; } foo.count = 0; foo(1); foo(2); console.log(foo.count); // ? 复制代码 此时的 foo.count 的值是多...