reading notes for code fellows
This is important because the ability to understand why your code is running the way it is and in what order/ what all the different errors refer to is essential in your ability to debug effectively.
The call stack is primarily used for function invocation. Since JavaScript is single-stack, functions are executed one at a time from top to bottom, making the call stack synchronous. A call stack uses the LIFO (last in first out) principle to temporarily store and manage function calls. A stack overflow occurs when there is a recursive function with no exit point, it will throw an error when the browser reaches the maximum call stack size.
functionOne () => {console.log('One')} functionTwo () => {functionOne(); console.log('Two')} functionTwo(); returns One Two because the second function is called at the end of the document, so it is pushed into the stack first, then it calls the first function, which is pushed into the stack after it, completes its task by logging one, pops out of the stack, and allows the second function to complete its task by logging two before poping out as well.Types of error messages
The simplest way to debug your code is to console.log() the variables you want to check. You also could use a debugger tool and set breakpoints in your code where you want it to pause so you can check all your variables. If you add a debugger statement, you can see the history of the code before it reaches the breakpoint. The call stack is easier to navigate in debugging if you use appropriately named functions, as it won’t show the names of the parents functions to anonymous ones.
Try catch allows you to handle errors properly, giving your code a fallback route so the rest of it can still be executed. To avoid runtime errors, you can also use tools like quokka, eslint, and typescript.
Quokka is something that sounds interesting, I may want to check that out at some point and see if iI like it.