js override console.log if not defined

后端 未结 7 710
庸人自扰
庸人自扰 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:34

    The following will achieve what you are looking for:

    window.console && console.log('foo');
    
    0 讨论(0)
提交回复
热议问题