How to fix “foo is not defined” error reported by JSlint? [duplicate]

自作多情 提交于 2019-11-27 02:01:46

问题


Possible Duplicate:
JSLint: was used before it was defined

I run JSlint and saw errors like that:

'foo' is not defined.
var x = foo();

foo is a function defined in another JavaScript file foo.js. As I understand there is no "import / require" directives in JavaScript to reference the foo function defined in another source file.

How can I fix this error repoted by JSlint?


回答1:


Use the global directive to tell JSLint about foo's assumed existence.

/*global foo */

http://www.jslint.com/help.html#global



来源:https://stackoverflow.com/questions/11957977/how-to-fix-foo-is-not-defined-error-reported-by-jslint

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