A simple and relatively effective way to debug your front end JavaScript code is
to add the console.log(var)
to parts where you want to check if the output
matches the expected value. Similar technique as adding break points to your
code.
The console.log
output is visible in the browserโs console:
For Google Chrome and Mozilla Firefox you can acceess the developer tools by
pressing the Control+Shift+I
(on Linux and Windows) or Command+Option+I
(on
Mac), and find the console tab.
As a next a bit more advanced step, Chrome browser has by default integrated the developer tools to debug front end code more quickly and efficiently.
To debug regular expressions on the fly, you can use the online free regex tool and debugger at Regex 101.