JSLint:意外结束

Sta*_*bie 0 javascript jquery jslint

$.fn.hasScrollBar = function () {
    "use strict";

    return this.get(0).scrollHeight > this.height();
}
Run Code Online (Sandbox Code Playgroud)

JSLint抱怨并说:

Unexpected '(end)'.
}
line 5 character 1
Run Code Online (Sandbox Code Playgroud)

有什么想法有什么不对吗?

Jam*_*ice 6

因为它是一个函数表达式(不是函数声明),所以它应该以分号结尾:

$.fn.hasScrollBar = function () {
    "use strict";

    return this.get(0).scrollHeight > this.height();
}; //<-- Semi-colon here
Run Code Online (Sandbox Code Playgroud)

JSLint抱怨"意外结束",因为它不希望在结束}字符处遇到输入结束.