Console surprises me every time. If there is no problem with the program, I will never use it. It is the first thing that comes to mind when there is something wrong with the program. Summarize the console methods I’ve used and remember the time we spent debugging together. The JavaScript native has no console object by default, which is a built-in object provided by the host object (that is, the viewer). Used to access the debug console, which may be different in different browsers. The Console object has two common uses: 1. Displays error messages when the web page code is running. 2. Provides a command line interface for interacting with web code.

Methods:

  1. Assert (a, b) The first argument is an expression and the second argument is a string. The second argument is printed only if the first argument is false, otherwise there is no result.

  2. Clear () clears all output from the current console, setting the cursor back to the first line.

  3. Count () is used to count how many times it is called. CountReset reset ()

  4. Error () is preceded by a Red Cross, indicating an error, and displays the stack where the error occurred.

  5. Group () is used to group displayed information, which can be collapsed and expanded. GroupEnd () Ends the inline group

GroupCollapsed () is similar to the console.group method, with the only difference being that the content of an collapsed group collapses rather than unfolds during the first display.

  1. Log () Output information Info () Console. log alias, output information

  2. Table () converts compound type data to table display.

  3. Time () Indicates that the timing starts. TimeEnd () indicates that the timing ends

  4. Trace () traces the call to the function

  5. Warn () Outputs warning messages

  1. Dir () displays the properties of the specified JavaScript object in the console through an interactive list that resembles a file tree.