finding out if console is available

后端 未结 8 899
温柔的废话
温柔的废话 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:27

    Simplest way would be:

    if (window.console){
       console.log('do something');
    }
    

    instead of just writing:

    console.log('do something');
    

提交回复
热议问题