Error Handling and Debugging Overview
Introduction
Error handling is a process of dealing with errors that occur during the execution of a program. There are some important concepts to know about how the javascript interpreter works. One of the most important aspects of programming is understanding how your code is executed. This is especially important when it comes to error handling and debugging. In this article, we’ll take a look at the order of execution, execution context, and the stack.
Order of Execution
The order of execution is the order in which your code is executed. For example, if you have a line of code that is executed after a line of code that throws an error, the line of code that is executed after the error will not be executed.
Execution Context
The execution context is the environment in which your code is executed. This includes the global scope, the function scope, and the block scope. For example, if your code is executed in the global scope, it will have access to the global variables. However, if your code is executed in a function scope, it will only have access to the variables in within that function.
The Stack
The stack is a data structure that stores information about the order in which your code is executed. In a more technical and abbreviated way, it’s a LIFO (Last In First Out) data structure. It let’s you know how the JavaScript Interpreter sees your code. In the stack, the last function that enters the stack structure is the first one that is taken out.
Ending Thoughts
By understanding these concepts, you’ll be better equipped to debug your code and handle errors. As this is an overview, there will be some dedicated articles for each of these concepts soon.