【发布时间】:2011-09-27 16:55:27
【问题描述】:
考虑以下代码:
/*global console:true */
(function () {
"use strict";
//set console for browsers without debugger
if (!console) {
console = {
log: function() {}
};
}
});
这会抛出一个错误:
Error:
Problem at line 7 character 9: Read only.
console = {
Problem at line 7 character 9: Stopping. (3% scanned).
然而,控制台已被设置为可写全局,因此它不应该是只读的。
关于如何规避或解决此问题的任何建议?
谢谢。
【问题讨论】:
-
我试图在 jslint.com 网站上重现此内容,但没有成功,除了将
true替换为false。你用的是命令行工具,还是网站? -
@bbg,我正在网站上尝试,jslint.com。很奇怪,您无法复制它。我又试了一次,没有成功。
-
啊哈,你有没有选中
Assume console, alert...框?如果是这样,请尝试取消选中它。 -
@bbg,成功了。我应该考虑到这一点。非常感谢。
-
优秀。我添加了相同的评论作为答案,但现在它只是多余的。
标签: javascript debugging jslint