JavaScrip this 的四种绑定方式
JavaScrip this 的四种绑定方式默认绑定// 非严格模式, 独立函数调用的 this 全部指向 windowfunction foo() { console.log(this);}// window.foo();foo(); // window// 不管定义的位置, 主要是谁调用let obj = { name: "why", fn: function () { console.log(this); }}let bar = obj.fn
原创
2022-03-22 10:10:37 ·
80 阅读 ·
0 评论