js override console.log if not defined

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

    Or, in coffeescript:

    window.console ?=
        log:-> #patch so console.log() never causes error even in IE.
    

提交回复
热议问题