It is common to have errors while writing codes and the errors can be due to syntax or logical. These errors create a lot of ambiguity in the logic and understanding of both users and programmers. There can also be errors in the code which can remain invisible to the programmer’s eye and can create havoc.
To identify these errors we need Debuggers that can go through the entire code or program, identify the errors and also fix them.
Most modern browsers come with built-in debugging tools that allow you to step through your code line by line and inspect variables and expressions. This can be a powerful tool for identifying and fixing bugs.
2. Use of console.log() method
3. Setting Break Points
The console.log() is a good way to debug errors but setting breakpoint is a faster, efficient and better method. In this method, Breakpoints are set in code which stops the execution of code at that point so that the values of variables can be examined at that time.
Here are some advantages of using Breakpoints over console.log() method:
- In console.log() method the user has to understand the code and manually put console.log() at points in the code. But in the breakpoints method, we can set breakpoints through Developers tool anywhere in code without even knowing it.
- In console.log() method we have to manually print values of different variables but at a certain breakpoint, all the values of all variables are displayed automatically in the Developers tool.