Debugging

This is the process of finding and resolving identified bugs within computer programs, software, or systems.

In JavaScript, the three frequently used methods in debugging an application includes:

  • Using the console within a browser enabled platform
  • Using a breakpoint
  • Using a debugger

Using the Console

The function console.log(<value>) can be used to display JavaScript values in the Console tab of our Devtools. This method is quite helpful, but it's not the most efficient approach. Notwithstanding, there are different ways to use the console for debugging.

Watch this Video on ways to use the console for debugging

Setting Breakpoints

A single or multiple breakpoints can be set in a debugger window. At each breakpoint, code execution will be paused, making it possible to examine available JavaScript values.

Watch this Video on how to set different breakpoints

The Debugger statement

The debugger keyword can be used to temporarily pause the execution of JavaScript code. This is similar to setting a breakpoint, however it has no effect on browsers that don't have support for it.

Watch this Video on how to use the Debugger