How to quickly and conveniently disable all console.log statements in my code?

后端 未结 28 2500
深忆病人
深忆病人 2020-11-22 16:48

Is there any way to turn off all console.log statements in my JavaScript code, for testing purposes?

28条回答
  •  轮回少年
    2020-11-22 17:31

    If you're using IE7, console won't be defined. So a more IE friendly version would be:

    if (typeof console == "undefined" || typeof console.log == "undefined") 
    {
       var console = { log: function() {} }; 
    }
    

提交回复
热议问题