zequet asked:
How I debug JavaScript?
By using a JavaScript debugger. Visual Studio can do it, but, to best of my knowledge, it only works with IE (maybe Edge). Chrome browser has a fully functional JavaScript debugger, but by far not so convenient. There is a good number of other projects with JavaScript debuggers; just do your Web search.
—SA