[removed] How do I print a message to the error console?

前端 未结 18 2202
闹比i
闹比i 2020-12-04 04:52

How can I print a message to the error console, preferably including a variable?

For example, something like:

print(\'x=%d\', x);
18条回答
  •  难免孤独
    2020-12-04 05:25

    console.error(message); //gives you the red errormessage
    console.log(message); //gives the default message
    console.warn(message); //gives the warn message with the exclamation mark in front of it
    console.info(message); //gives an info message with an 'i' in front of the message
    

    You also can add CSS to your logging messages:

    console.log('%c My message here', "background: blue; color: white; padding-left:10px;");
    

提交回复
热议问题