In our daily development, console.log()
debugging is often used but rarely used console.dir()
. So what is the difference between the two?
1. Comparison
-
String
//Number
/ As you can seeObject
,Array
there is no difference
-
Function
PrintFunction
, you can seeconsole.dir
that the corresponding attributes/methods are printed out
DOM
Node
printingdom
node, you can see:console.log
printing node,console.dir
printingdom
properties and methods
2. Expand
There is also a less commonly used console.count
function, which is to print the number of times a certain method has been called, for example: