When it comes to debugging JavaScript in Chrome devtools, there are two different camps: the console.log
fans and the debugger/breakpoint maximalist. I often switch between the two depending on what problem I am tackling. There is a third option that is kind of in the middle. Logpoints provide us with a breakpoint-like mechanism that logs variables instead of halting the execution.
All variables that are present in the current context can be logged using this.
Here’s a video for the steps:
This is particularly useful when dealing with third-party scripts which you cannot modify using your source code. Plus it saves a bunch of console.log/debugger cleanup once you are done debugging.
And that is it for this quick tutorial! Hope you found this tip useful and will start using more of it in your day-to-day debugging. Happy coding!
While working on a project, I wanted to do an integrity check of a file…
Popovers have been a problem that was typically solved by using a third-party solution. But…
Node.js 20.6 added built-in support for the .env file. This is an excellent addition to the platform…
Object destructuring is a powerful ES 6 feature that can help developers write cleaner code.…
Have you felt particularly annoyed by the time it takes to clone a large repository,…
Within a React or Next.js app, if you encounter the error "Hydration failed because the…