JSLint错误:意外'这个' [英] JSLint Error: Unexpected 'this'

查看:119
本文介绍了JSLint错误:意外'这个'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



对于两个属性赋值,JSLint说:意外'这个'。如何更正我的代码?

解决方案

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



<我的建议是:告诉JSLint关闭





或者根本不使用JSLint。


Having trouble understanding why JSLint is surprised by my use of this in the following code:

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

For both property assignments, JSLint says: Unexpected 'this'. How do I correct my code?

解决方案

Your code might be perfectly correct (it might also be problematic, depending on how you call testConstr).

My suggestion is: tell JSLint to shut up

Or don't use JSLint at all.

这篇关于JSLint错误:意外'这个'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆