Home > Article > Web Front-end > Detailed explanation of js debugging tool Console command_javascript skills
1. Commands to display information
The most commonly used one is console.log.
2: Placeholder
The above concentration of console supports the placeholder format of printf. The supported placeholders are: characters (%s), integers (%d or %i), floating point numbers (%f) and objects (%o)
3. Information Grouping
Effect:
4. View object information
console.dir() can display all properties and methods of an object.
Effect:
5. Display the content of a node
console.dirxml() is used to display the html/xml code contained in a node of the web page.
Effect:
6. Determine whether the variable is true
console.assert() is used to determine whether an expression or variable is true. If the result is no, a corresponding message is output to the console and an exception is thrown.
1 is a non-zero value, which is true; while the second judgment is false, an error message is displayed on the console
7. Track the calling trace of the function.
console.trace() is used to trace the calling trace of the function.
Console output information:
8. Timing function
console.time() and console.timeEnd() are used to display the running time of the code.
The running time is 38.84ms
9. Performance analysis of console.profile()
Performance analysis (Profiler) is to analyze the running time of each part of the program and find out where the bottleneck is. The method used is console.profile().
Explain that during the LZ test, alert was not added to All(), and the control bar had no output. After adding it, there was a performance analysis table. The reason is not yet clear. If you know, you can comment.