What is console.log?

前端 未结 22 2860
面向向阳花
面向向阳花 2020-11-22 00:41

What is the use of console.log?

Please explain how to use it in JavaScript, with a code example.

22条回答
  •  清歌不尽
    2020-11-22 01:06

    There is nothing to do with jQuery and if you want to use it I advice you to do

    if (window.console) {
        console.log("your message")
    }
    

    So you don't break your code when it is not available.

    As suggested in the comment, you can also execute that in one place and then use console.log as normal

    if (!window.console) { window.console = { log: function(){} }; }
    

提交回复
热议问题