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

后端 未结 28 2545
深忆病人
深忆病人 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:22

    Just change the flag DEBUG to override the console.log function. This should do the trick.

    var DEBUG = false;
    // ENABLE/DISABLE Console Logs
    if(!DEBUG){
      console.log = function() {}
    }
    

提交回复
热议问题