A command to display information

1: 2: 3: 4: Common console commands 5: 6: 7: 8: 14:15:Copy the code

The most common is console.log.

Two: placeholders

Console supports the placeholder format for printf: characters (%s), integers (%d or % I), floating point numbers (%f), and objects (% O)

   1: 
Copy the code

Effect:



3. Information grouping

1: 2: 3: 4: Common console commands 5: 6: 7: 8: 25:26:Copy the code

Effect:



4. View object information

Console.dir () displays all of an object’s properties and methods.

   1: 
Copy the code

Effect:



Display the contents of a node

Console.dirxml () is used to display the HTML/XML code contained in a node of the web page.

1: 2: 3: 4: Common console commands 5: 6: 7: 8:
       
9:

My blog: www.ido321.com

10:

Program enthusiasts :259280570, welcome to join

11:
12: 16: 17: Copy the code

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 message is printed to the console and an exception is thrown.

   1: 
Copy the code

1 is a non-zero value, true; The second judgment is false and displays an error message on the console



Trace the call trace of the function.

Console.trace () is used to trace function calls.

   1: 
Copy the code

Console output:



8. Timing function

Console.time () and console.timeend (), which display the running time of the code.

   1: Copy the code