【发布时间】:2011-04-15 15:20:20
【问题描述】:
你推荐哪种解决方案,第二种更简单(代码更少),但使用它有缺点?
首先:(设置全局调试标志)
// the first line of code
var debug = true;
try {
console.log
} catch(e) {
if(e) {
debug=false;
}
};
// Then later in the code
if(debug) {
console.log(something);
}
第二:覆盖console.log
try {
console.log
} catch(e) {
if (e) {
console.log = function() {}
}
};
// And all you need to do in the code is
console.log(something);
【问题讨论】:
标签: javascript console firebug