gpt4 book ai didi

javascript - JSLint 错误 : Unexpected 'this'

转载 作者:IT王子 更新时间:2023-10-29 03:08:38 26 4
gpt4 key购买 nike

无法理解为什么 JSLint 对我在以下代码中使用 this 感到惊讶:

function testConstr (x) {
'use strict';
this.joker = "Whyyy sooo seriousss?";
this.x = x;
}

对于这两个属性分配,JSLint 会说:意外的“this”。如何更正我的代码?

最佳答案

您的代码可能完全正确(它也可能有问题,具体取决于您如何调用 testConstr)。

我的建议是:让 JSLint 闭嘴

enter image description here

或者根本不使用 JSLint。

关于javascript - JSLint 错误 : Unexpected 'this' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30314944/

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