Javascript JSLint警告

Javascript JSLint警告,javascript,jslint,Javascript,Jslint,我无法理解为什么JSlint会发出以下警告: 意外的“这” 期望“;”而是看到了“capWord” 期望“;”而是看到了“我” 停止 代码如下:它运行时没有任何错误。我只是想让它符合JSLint "use strict"; function capWord(inStr) { this.inStr = inStr; //Unexpected 'this' } capWord.firstIndex = function(inStr) { document.write(this.upp

我无法理解为什么JSlint会发出以下警告:

意外的“这” 期望“;”而是看到了“capWord” 期望“;”而是看到了“我” 停止 代码如下:它运行时没有任何错误。我只是想让它符合JSLint

"use strict";

function capWord(inStr) {
   this.inStr = inStr; //Unexpected 'this'
}

capWord.firstIndex = function(inStr) {
   document.write(this.upper(inStr[0])); //Unexpected 'this'
   this.space(inStr); //Unexpected 'this'
}

capWord.space = function(inStr) {
   for(var i=1;i<inStr.length;i=i+1) { //Unexpected 'for'; Expected ';' and instead saw 'i'
   document.write(inStr[i]);
   if (inStr[i] == " ") {
        document.write(this.upper(inStr[i+1]));
        i = i+1;
    }
  }
}

capWord.upper = function(charUpper) {
   return charUpper.toUpperCase();
}

capWord.firstIndex("lfadjadjfkaru wish this wouldnt be hapeingig");

如果您指出警告出现在哪一行并包含所有代码,这将非常有用。然而,由于不是所有的代码都在这里,我打赌是缺少大括号或类似的东西更好…在适当的行中添加一条带有错误的注释。代码在运行时会抛出错误吗?如果不是,这甚至不应该是一个问题,只需阅读错误消息。上面写着“期望”而是看到了“capWord”。这是因为在第9行结束的赋值语句末尾没有分号。还有,inStr=inStr应该做什么?您还需要安排文档不抛出未定义的错误。@torazaburo我的解释不正确,我应该在发布之前尝试修复。但为了重现此错误,请尝试在此处粘贴OP的代码:您可以在中格式化代码,并使用附加到文件顶部以忽略某些情况。