Console. Log (): The most common method for debugging. It is used to display information in the console window.
console.log(123); //123
Console. Warn (): when outputting information, add a Yellow Triangle at the beginning to indicate a warning.
Console. Warn ('output warning information'); // output warning information
Console. Error (): when outputting information, add a Red Cross at the beginning to indicate an error.
Console. Error ('output error information'); // output error message
Console. Assert (): used to verify whether a condition is true. If it is false, an error message specified in advance is displayed.
Console. Assert (true = false, 'judgment condition is not true '); // The Judgment condition is not true.
Console. Time () and console. timeend (): used to calculate the exact time spent on an operation
//time: 0.06msconsole.time(‘time‘);for (var i = 0; i > 100000000; i++){}console.timeEnd(‘time‘)
Console. dirxml (): used to display the code structure of web page elements
// Display the code structure of the current element var odiv = Document. getelementbyid ('one'); console. dirxml (odiv)
Console. Group () and console. groupend (): these two methods are used to group the displayed information. It is useful only when a large amount of information is output. It is divided into a group of information and can be folded/expanded with the mouse.
Console. group ('group 1') console. log ('group 1 Information 01'); console. log ('group 1 Information 02'); console. groupend ('group 1') console. group ('group 2') console. log ('group 2 Information 01'); console. log ('group 2 Information 02'); console. groupend ('group 2 ')