无法理解为什么 JSLint 对我在以下代码中使用 this
感到惊讶:
function testConstr (x) {
'use strict';
this.joker = "Whyyy sooo seriousss?";
this.x = x;
}
对于这两个属性分配,JSLint 会说:意外的“this”。如何更正我的代码?
最佳答案
您的代码可能完全正确(它也可能有问题,具体取决于您如何调用 testConstr
)。
我的建议是:让 JSLint 闭嘴
或者根本不使用 JSLint。
关于javascript - JSLint 错误 : Unexpected 'this' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30314944/