Open In App
Related Articles

What is the use of debugger keyword in JavaScript ?

Like Article
Save Article
Report issue

Debugging is a very important aspect of programming to determine why a system or application is misbehaving. It is a process of testing and finding errors to reduce bugs from computer programs. In this article, we will learn about the debugger keyword in JavaScript. To know more about debugging check Software Engineering | Debugging.

Debugger keyword in JavaScript: The debugger keyword is one of the debugging tools in JavaScript. It is very common to have errors in the program while writing the codes these errors may be logical errors or syntax errors. Debugging is one of the ways to identify the critical as well as small errors that decrease the efficiency of the program. In javascript when the debugger keyword is turned on, It stops the execution of JavaScript code, and if debugging function available it calls the debugging function. Otherwise, it has no effect. 

Syntax: The general syntax of the debugger keyword. 


Example: It will describe the debugger keyword in JavaScript.


<!DOCTYPE html>
    <p id="para"></p>
      When we turned on the debugger keyword, 
      the code below should stop executing before
      it executes the third line.
      let a = 10 * 5;
      document.getElementById("para").innerHTML = a;


Output: The HTML code is loaded on the web browser with the static content in the HTML but the dynamic change will not appear at first on the web browser because above the DOM function the execution of the script code is stopped when the debugger keyword appears in the script code. The execution of the code will be resumed only when the resume option will be clicked.

Last Updated : 27 Aug, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads