From the Duckett JS book:
CHAPTER 10: ERROR HANDLING & DEBUGGING
- THE STACK:
The JavaScript interpreter processes one line code at a time. When statement needs data from another function, it stacks the new function on top of the current task.If a JavaScript statement generates an error, then it throws an exception. At the point, the interpreter stops and looks for exception-handling code.
- HOW TO DEAL WITH ERRORS: You can two things with the errors:
1- Debug the Script to fix errors. 2- Handle errors gracefully.
The console is a helpful things, it can define the area in which the error is located. In JavaScript there is seven types of error objects.