What is Code Debugging?
While coding or writing the program, we can make many mistakes, such as logical errors, syntax errors, etc. A debugging allows us to find the location/point where an error has occurred because in the debugging, we can execute our code as one line at a time. Once we find the point where we have made a mistake, we can make appropriate changes to correct the mistakes. The debug tools also allow us to make temporary changes to the program's code. This entire process of correcting a code after finding out the errors is `QAZ!qknown as debugging.
In short, we can say that Code Debugging is a process of finding and correcting the programming errors.
As it is evident that debugging is not an easy task because it requires a lot of practice and experience, so fortunately all modern web-browsers have their own built-in Debuggers. The web-browser gives us the control to turn on or off the Debugging whenever we wanted to use it and it also allows us to set breakpoints (where the execution of the program's code can stop) and we can examine the variable when the code is executing.
The console.log () Method
Syntax of console method
We can understand it more clearly with the help of an example:
How to set breakpoints?
The debugger Keyword
Explanation of program
In above program, we have created a variable x in which we have multiplied 15 into 5 and used the debugger keyword for setting up a breaking point. When we perform the debugging process, the execution of program will stop at that line, and we can examine the value. If any changes are not required, then we can resume the execution.
Let's see an example with practical
Let us see how you can open the console on different modern browsers
These are the following five major modern browsers that support debugging.