使用 console.log() 时 JSLint 抛出错误

JSLint throwing error when using console.log()

我使用的文本编辑器是Brackets。当我尝试在任何 JS 文件中使用 console.log 时遇到错误消息。

1 - Create/Open 一个 JS 文件

2 - 输入 console.log('hello world');

3 - 保存文件

JSLint 问题:

error message in JSLint 'console' was used before it was defined.

使用devel选项:

true if browser globals that are useful in development should be predefined, and if debugger statements and TODO comments should be allowed. It adds the same globals as this directive:

/*global
alert, confirm, console, prompt
*/

Be sure to turn this option off before going into production.

所以在脚本的顶部添加这一行:

 /*jslint devel: true */