Hoisting Cats: The Lowdown on JavaScript Execution Context
Because understanding how your code runs matters
JavaScript is easy . Until it breaks — then nothing makes sense. Console logs tell you it’s undefined
in that annoying little red error. Or things just get set incorrectly, even though you think your logic is infallible. It happens a lot, especially for beginners.
So what exactly went wrong?
When something blips out in your JavaScript code, it’s probably because you’ve messed up the execution context in some way.
People say that execution context is an advanced concept — but I think it is fundamental to being a robust JavaScript developer because it governs the way your code runs.
When you understand execution contexts, you understand how the JavaScript interpreter sees the code rather than how you visually interpret it.
What Exactly is an Execution Context?
In theory, you could write your JavaScript code as one big linear procedural chain. However, for human comprehension purposes, this is not the most effective method.
Packages, methods, functions and whatever else you use to segment and group ideas together, the execution context how the JavaScript compiler…