JSLint错误:"将调用移动到包含该函数的parens"

Sam*_*Sam 73 javascript debugging jquery compiler-errors jslint

JSLint对此错误的意义是什么?它应该如何改写?

Error: Problem at line 78 character 3: Move the invocation into the parens that contain the function: })(jQuery);

Mat*_*att 118

要传递JSLint的标准,需要像这样编写:

}(jQuery));

虽然我认为特定的标准有点主观.在我看来,这两种方式似乎都很好.

(function () {})() 因为你包装了完整的函数,然后调用它,对我来说更有意义

(function () {}()) 看起来你正在将函数调用的结果包装在一个parens中......

  • 什么是JSLint这样做的动机? (16认同)
  • http://stackoverflow.com/questions/1450721/solution-for-jslint-errors/1481517#1481517 (8认同)