These are my reading notes for Code Fellows
Function execution occurs in a hierarchical manner, one at a time, from the top to the bottom
Call stack uses “last in first out” principle (AKA LIFO)
The following line of code would run in order from 1-3 (firstFunction through thirdFunction):
function firstFunction(){
throw new Error('Stack Trace Error');
}
function secondFunction(){
firstFunction();
}
function thirdFunction(){
secondFunction();
}
thirdFunction();
(source)
(source)
Think of yourself standing on a queue, in a grocery store cash point. You can only be attended to after the person in front of you have been attended to. That’s synchronous. This is what we mean by “manage function invocation”. (source)
JavaScript is synchronous in the same way!
Stack overflow is when a function calls itself but doesn’t have an exit point. It runs over and over. Example as follows:
function helloTim() {
helloTim();
}
helloTim();
console.log()
is invaluable in debugging