为什么JSHint显示缺少'使用严格'带参数的自调用函数结束时的错误

时间:2014-10-03 12:34:59

标签: function jshint use-strict self-invoking-function

jsHint在自调用函数结束时使用标准模块模式生成错误,我传入参数:}(window.document, jQuery))

任何人都知道为什么?

var kaApp = (function (document, $) {
  'use strict';
    var testStrict = {p1:10, p2:15, p3:20};
    // x = 3;
    var docElem = document.documentElement;
    console.log(testStrict);
    if(foo === undefined){
        var foo = 'foobar';
    }
    var setUserAgentString = function userAgent() {
        docElem.setAttribute('data-useragent', navigator.userAgent);
    };

    console.log('userAgentInit name: ' + setUserAgentString.name);

    return {
        init: function() {
            setUserAgentString();
            $(document).ready(this.afterDomReady);
        },
        afterDomReady: function() { 
            // Executes after DOM ready
            console.log('----- DOM is ready!!!!');
        }
    };

}(window.document, jQuery)); // error here "missing 'use strict' statement"

kaApp.init(document, jQuery);

0 个答案:

没有答案