How could you track when and where the 'counter' variable changes using DevTools?
let counter = 0;
function incrementCounter() {
counter++;
updateUI(counter);
}
Watch expressions provide real-time variable monitoring: 1) In DevTools, you can add a watch expression for the 'counter' variable, 2) The watch panel will display the current value of the variable at all times, 3) The value updates live as you step through code or when execution pauses at breakpoints, 4) Changes in the value are visually highlighted, making them easy to notice, 5) This eliminates the need for numerous console.log statements, 6) Multiple variables can be watched simultaneously, 7) Expressions can be complex, not just simple variables (e.g., 'counter > 10' or 'user.addresses.length'), 8) This provides continuous visibility into the application state without modifying the code, making it ideal for tracking changes to important variables.