javascript 在通过JSLint运行时对我大喊大叫,我不知道为什么。
/*jslint browser: true, devel: true, evil: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, newcap: true, immed: true */
var foo = function() {
try {
console.log('foo');
} catch(e) {
alert(e);
}
try {
console.log('bar');
} catch(e) {
alert(e);
}
};
foo();
它告诉我:
第 12 行字符 11 处的问题:'e' 已定义。
} catch(e) {
看来我有第二个不高兴catch(e)
。为什么这会是一个问题?它不是简单地将 e 设置为 catch 块内的局部变量吗?我是否需要为函数中所有捕获的错误唯一命名局部变量?