Using Chrome DevTools (Classic and Powerful)
-
Open DevTools: Press F12 or Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (Mac) to open Chrome DevTools. Alternatively, right-click on the page and select Inspect.
-
Go to the Sources Tab: This tab allows you to view and step through your JavaScript code.
-
Set Breakpoints: In the “Sources” tab, navigate to the file you’re working with, and click on the line number where you want to set a breakpoint. The code execution will pause when it reaches this line, allowing you to inspect variables, step through the code, and debug.
-
Use the Console: You can also use the “Console” tab to interact with the page and run JavaScript expressions directly.
Chrome DevTools is a powerful built-in tool that allows you to view and debug JavaScript code with ease. It’s widely used by developers for all kinds of web debugging tasks.