为什么以下代码会在 JSHint 中触发 "Expected an assignment or function call and instead saw an expression."?我认为这是保护一个块不执行,如果一个特定的变量或变量未定义的正确方法...
!function($) {
"use strict";
// jQuery-based code here
$('.test').show();
}(window.jQuery);
!function($){"use strict";}(window.jQuery);
触发了错误,而(function($){"use strict";}(window.jQuery));
没有。在JavaScript中,函数调用比!
运算符具有更高的优先级。 - Prusse