Debugging is essential because there are many errors that are not giving any kind of messages so to find out that we debug the code and find out the missing point.
Example 1: Using console.log() Method
Output: Here we can see that the first console.log gives undefined because we just define the var a but does not assign any value. We can open the console by pressing the F12 key or by clicking the right button and then selecting inspect.
Example 2: Debugger Keyword
Output: After writing the debugger keyword, when we run the code then in the console this kind of debugger panel will show up where we make breakpoints and play/pause to check the value and understand according to it. We can open the console by pressing the F12 key or by clicking the right button and then selecting inspect.
Breakpoints are the place where code stops running, by this if we are ever stuck in the infinite loop then we can trace it by this.
Please Login to comment...