The console object

(1) Method

console.log(text,text2,...)   // Used to output information in the console window. It can take multiple arguments and concatenate their results for output. If the first argument is a format string (using format placeholders), the console.log method replaces the placeholders with subsequent arguments in turn before printing.
console.info()   // In the console window, the output information will be preceded by a blue icon.
console.debug()  // In the console window, the output information will be preceded by a blue icon.
console.warn()  // Add a yellow triangle to the front of the output message, indicating a warning;
console.error()  // The output message is preceded by a Red Cross, indicating an error, and the stack where the error occurred is displayed
console.table()  // You can convert complex data to tabular display.
console.count()  // To count how many times it is called.
console.dir()    // Inspect an object and display it in a format that is easy to read and print.
console.dirxml()  // Display DOM nodes as a directory tree.
console.assert()  // Takes two arguments, the first an expression and the second a string. The second argument is printed only if the first argument is false, otherwise there is no result.

// These two methods are used for timing, so you can calculate the exact time an operation takes.
console.time()
console.timeEnd()
// The time method indicates the start of the timer, and the timeEnd method indicates the end of the timer. They take the name of the timer. After calling the timeEnd method, the console window displays "Timer name: Time consumed."

console.profile()  // To create a new profile, which takes the name of the profile.
console.profileEnd()  // To end a running performance tester.

console.group()
console.groupend()
// These two methods are used to group the displayed information. It is only useful for output of large amounts of information, grouped into groups that can be folded/expanded with the mouse.
console.groupCollapsed()  // Displays of information into groups that collapse rather than unfold during first displays.

console.trace()  // Displays the invocation path of the currently executing code on the stack.
console.clear()  // Used to clear all output from the current console, putting the cursor back to the first line
Copy the code