狄烁STEC的试验场

hello earth

导航

2011年12月13日 #

console.log在webkit中apply

摘要: 为了调试方便,我们有时候会这样写log() 1 /** @define {boolean} */ 2 var DEBUG = true; 3 4 function log() { 5 if (DEBUG) { 6 console.log.apply(this, arguments); 7 } 8 } 9 10 function foo(bar) {11 log('bar is %s.', bar);12 }发布代码的时候只要在Closure Compiler的参数里设置 DEBUG=false 就不用手动删除每一条log()调用了。但是上面的代码在we... 阅读全文

posted @ 2011-12-13 16:55 狄烁STEC 阅读(1547) 评论(0) 推荐(0) 编辑