DEV Community

Discussion on: Stop Console.Logging! This is How to Use Chrome to Debug JavaScript

Collapse
 
salvan13 profile image
Antonio Salvati 🦊

console.log is useful.
Specially if you can't stop the code execution with breakpoints because you are debugging async code, or when you need to print some info in the console often and you don't want stop the code execution each time.

Collapse
 
songthamtung profile image
songthamtung

Thanks for reading Antonio!

On the contrary, console.log() is actually not useful for async functions since it is non-blocking i.e. the result would be pending. If you want to console.log() async code, you would have to either precede the method with await or chain it with then. In this scenario, a breakpoint would be more efficient.

For readers who are unaware:

An asynchronous call requests a transfer that will be performed in its whole(entirety) but will complete at some future time.

Nevertheless, I do agree that printing some info into the console without stopping the code execution each time is useful depending on the situation.