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:
-
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.
-
Clear () clears all output from the current console, setting the cursor back to the first line.
-
Count () is used to count how many times it is called. CountReset reset ()
-
Error () is preceded by a Red Cross, indicating an error, and displays the stack where the error occurred.
-
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.
-
Log () Output information Info () Console. log alias, output information
-
Table () converts compound type data to table display.
-
Time () Indicates that the timing starts. TimeEnd () indicates that the timing ends
-
Trace () traces the call to the function
-
Warn () Outputs warning messages
- Dir () displays the properties of the specified JavaScript object in the console through an interactive list that resembles a file tree.