gpt4 book ai didi

javascript - 与词法 this 相反

转载 作者:行者123 更新时间:2023-11-30 08:27:49 25 4
gpt4 key购买 nike

这是一个关于术语的问题。

考虑到有一个方法使用词法this:

var foo = {
method: function () {
console.log(this, ' is the context');
}
};

foo.method();

this 在绑定(bind)到不同的上下文或分离时调用方法时的常规术语是什么?

bazThatAcceptsACallback(foo.method);
foo.method.bind(baz)();
(0, foo.method)();

在这种情况下,我经常将其称为“非词汇 this”或“上下文 this”,但我从未在官方或可信来源中遇到过这些或类似术语。

最佳答案

词法 this 的反义词是 dynamic 这个

但是,请注意词法 this 不是您在 function 片段中显示的内容,而是箭头函数所具有的 this

关于javascript - 与词法 this 相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42581908/

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