Class 10
Troubleshooting Javascript.
There are more than one type of error you might encounter is Javascript. The first one might be a syntax error, a syntax error is unreadable code. It’s code that can’t be read by the broswer because there’s something wrong with it. A logic error is another type of error, this is when the code is writtenly correctly but logically doesn’t make sense.
In previous labs I have come accross these errors, sometimes it’s from something as simple as a missing character and other times it’s a case of me writing things the wrong way round or getting the scope incorrect.
The Javascript debugger
The Javascript debugger is a great tool, allowing you to turn different things on and off to find an issue by process of elimination and others ways too.
Using ‘debugger’ in your code adds a pause to your script, that way you can add a few pauses to narrow down when in the order of things the error is occuring. This is called adding a breakpoint.
The call stack is a mechanism for the browser to keep track of where it is when it calls multiple functions.