The console.log()
and the console.dir()
, today, do the same things. However, for some time, in firefox, the dir
was tasked with printing the element tree, while the log
was in charge of printing only one toString()
of the element.
It is also important to pay attention to the note that it can in the documentation of MDN:
! Non-standard
This Feature is non-standard and is not on a standards track. Do not use it on Production sites facing the Web: it will not work for Every user. There may also be large incompatibilities between implementations and the behavior may change in the Future.
That is, the method console.dir()
is not a standard method, which can cause problems in certain browsers that have not been implemented, and its use in production is not advisable.
In practice, today, with the changing shape that the console.log
in its implementation, the console.dir
became unnecessary.
Good information on this method: https://developer.mozilla.org/en-US/docs/Web/API/console/dir and https://stackoverflow.com/questions/11954152/whats-the-difference-between-console-dir-and-console-log
– Maury Developer