admin管理员组文章数量:1415467
I just tested my custom gallery script at JSLint.. and all errors where solved except for one.
The implied global error.. Is this really an error? Can I ignore it or should I work on it to solve this error..?
Thank you for your responses!
Error:
Implied global:
<bunch of vars and other stuff i dont know>
What does this mean? BTW I use JQuery Library.. maybe thats the problem^^..
I just tested my custom gallery script at JSLint.. and all errors where solved except for one.
The implied global error.. Is this really an error? Can I ignore it or should I work on it to solve this error..?
Thank you for your responses!
Error:
Implied global:
<bunch of vars and other stuff i dont know>
What does this mean? BTW I use JQuery Library.. maybe thats the problem^^..
Share Improve this question asked Jan 7, 2011 at 11:58 TomkayTomkay 5,16021 gold badges65 silver badges94 bronze badges3 Answers
Reset to default 6if you use externally declared variables like in this case, put a 'global' statement at the top of your file, like this:
/*global $, document */
JSLint documentation says:
Undefined Variables and Functions
JavaScript's biggest problem is its dependence on global variables, particularly implied global variables. If a variable is not explicitly declared (usually with the var statement), then JavaScript assumes that the variable was global. This can mask misspelled names and other problems.
JSLint expects that all variables and functions are declared before they are used or invoked. This allows it to detect implied global variables. It is also good practice because it makes programs easier to read.
Care for that error. Nearly every coding convention wants you not to use implied globals.
Variables can be declared using the var
keyword.
When writing JavaScript code for a browser, it is useful to indicate to JSLint that you are in browser mode, such as by including this:
/*jslint browser: true */
This should resolve 'document', 'setTimeout', and other typical browser defaults
Since jQuery is probably not being evaluated in the same context as your JavaScript, you'll need to let it be known that the ever-useful '$' is available with:
/*global $ */
本文标签: jqueryJSLint (Javascript Validator Website)Error Implied global Stack Overflow
版权声明:本文标题:jquery - JSLint (Javascript Validator Website) - Error! Implied global:- Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745184593a2646623.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论