What is the use of debugger keyword in JavaScript?

Forums JavaScriptWhat is the use of debugger keyword in JavaScript?
Staff asked 3 years ago

Answers (1)

Add Answer
Nayan Raval Marked As Accepted
Staff answered 3 years ago

The JavaScript debugger keyword places a breakpoint in the code. The debugger halts the program’s execution at the point where it is applied. We can now manually begin the execution flow. If an exception occurs, the execution will come to a halt again on that line. Consider the following scenario:

function display()  
{  
x = 10;    
y = 15;    
z = x + y;    
debugger;    
document.write(z);    
document.write(a);     
}     
display();

 

Subscribe

Select Categories