How to fix '$' was used before it was defined in both jslint and jshint using coding?

…衆ロ難τιáo~ 提交于 2019-12-02 09:29:50

Please use jslint comments. The following suggestion uses a few tricks. Having tricks in your code won't help for maintainability. Here is the code:

var myApplication = function () {
    "use strict";
    var $ = this.$, document = this.document, console = this.console;
    $(document).ready(function () {
        //...
        console.log("test");
    });
};

myApplication.call(this);

You cannot, and don't have to, fix it by coding. $ does in fact exist as global variable in a different file. That's exactly what /*global ... */ is for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!