gpt4 book ai didi

javascript - 'this' 在原型(prototype)内部时引用的是什么?

转载 作者:行者123 更新时间:2023-11-30 10:47:30 26 4
gpt4 key购买 nike

<分区>

Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};

从 Crockford's Good Parts 被盗。当代码返回“this”时,“this”在这种情况下引用什么?

当我在 js 代码中看到“this”时,我总是问自己这个问题,因为我知道 js 对这个词很时髦(即“this”在嵌套函数中使用时实际上引用了全局变量)

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com