finding out if console is available

后端 未结 8 886
温柔的废话
温柔的废话 2020-12-23 20:00

I was wondering, how can i find out with javascript if the console object is available?

i have the problem that if i forget to remove a debug output

8条回答
  •  温柔的废话
    2020-12-23 20:15

    A nice simple and short way of outputting to the console safely is as follows:

    window.console && console.log('Debug message');
    

提交回复
热议问题