How do you debug JavaScript in the browser developer tools?
The sources panel of the browser developer tools is the main place where you debug. A breakpoint stops the program at one line so that you can look at the values at that moment. You set one by clicking the line number next to your code, and you can drag it to a different line whenever you want to move it.
Conditional breakpoints are the feature that makes the tools practical on a large code base. Instead of stopping on every turn of a loop, you give the breakpoint a condition, and it only stops when that condition is true. For a bug that only happens with one item in a long list, that is the difference between a two-minute fix and an hour of clicking.
The step buttons are the other half of the job. Step over runs the next line without going into a function. Step into enters the function that is about to run. Step out leaves the function that you are inside. You use step over the most often, because it keeps you at the level of code that you actually care about.
Two more panels are worth knowing. The watch panel evaluates expressions in the middle of the paused code, so you can look at a variable or call a function on the current state without changing the program. The call stack panel shows how your program reached the current line, and that is how you find the code that called something you thought nobody called.
JavaScript also has a debugger statement that stops the program and opens the sources panel for you. If you put that statement in your source code, you can reload the page and the debugger is already waiting at exactly that line, which is much easier than hunting for the right file by hand.