Debugging is quite unpleasant due to type-less nature of variables and run-time interpretation on a browser.
JavaScript uses try..catch blocks for catching that erroneously uses a variable as the wrong data type.
Visual Studio has some JavaScript debugging support.