js override console.log if not defined

后端 未结 7 779
庸人自扰
庸人自扰 2020-12-05 04:41

Which solution do you recommend, the second is simpler ( less code ), but there are drawbacks on using it ?

First: (Set a global debug flag)

7条回答
  •  北海茫月
    2020-12-05 05:13

    window.console = window.console || {};
    window.console.log = window.console.log || function() {};
    

提交回复
热议问题