[英]The opposite of lexical this
This is a question about terminology. 这是关于术语的问题。
Considering that there is a method that uses lexical this
: 考虑到有一个使用词法
this
的方法:
var foo = {
method: function () {
console.log(this, ' is the context');
}
};
foo.method();
What's the conventional term for this
when the method is called when being bound to different context or detached? 什么是对传统的术语
this
时候,当被绑定到不同的环境或脱离被调用的方法?
bazThatAcceptsACallback(foo.method);
foo.method.bind(baz)();
(0, foo.method)();
I often refer to it as 'non-lexical this' or 'contextual this' in such cases, but I never met these or similar terms in official or trusted sources. 在这种情况下,我经常将其称为“非词汇性”或“上下文性”,但我从未在官方或可信赖的来源中遇到这些或类似术语。
You don't need different terms to describe the behavior of JS lexical this
for what it is referring to. 你并不需要使用不同的术语来描述JS词汇的行为,
this
东西它是指。 Its always the "context" the function is called in. Let it be the parent object or another binding - you can always say the lexical this
represent the context. 它总是在“背景”的函数被调用让它成为父对象或其他结合-你总是可以说词法
this
表示的上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.