Skip to main content
InterviewHubPRO
Section Overview
Q169

Question 169 of 536

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

32%
JavaScript & V8 Internals (536 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

What is the purpose of breakpoints in debugging

junior LevelCode ExampleHTTP & REST APIs

You can set breakpoints in the javascript code once the debugger statement is executed and the debugger window pops up. At each breakpoint, javascript will stop executing, and let you examine the JavaScript values. After examining values, you can resume the execution of code using the play button.

Practical Code Example

javascript
// Breakpoints pause code execution in DevTools to inspect Call Stack, Scope, and Memory:
function calculateDiscount(price, userType) {
  let discount = 0;
  if (userType === 'VIP') {
    discount = 0.25; // Set conditional breakpoint here: e.g. 'price > 500'
  }
  return price * (1 - discount);
}
calculateDiscount(600, 'VIP');