Event Loop
- the call stack - one thred == one call stack == one thing at a time
- push on top, pop off the top
- Web APIs are threads - where concurrency happens - make calls to.
- for NodeJS, it's C++ APIs
- task queue - when Web APIs is ready, it pushes callback to task queue
- event loop's simple job - look at stack and task queue, if stack is empty, it takes first item from task queue and pushes to stack
- setTimeout = 0, defer something until the stack is clearsetTimeout(function cb() {console.log('there)}, 0)
- setTimeout is not a guaranteed time to execution, it is mininum time to execution
- callbacks
- any function that another function calls
- async func - one that will get pushed to callback queue
To Review