The JavaScript Language is ...
- Single-Threaded
- Non-Blocking
- Asynchronous
- Concurrent
... it has ...
- A CallStack / Heap
- An Event-Loop
- A Callback Queue
- Other Available APIs
- DOM
- Ajax
- setTimeout
One Thread === one callstack === one thing at a time ...
One thing at a time, but not really ...
const multiply = (a, b) => a * b;
const square = (n) => multiply(n, n);
const printSquare = (n) => {
const squared = square(n);
console.log(squared);
};
printSquare(5);
Stack |
---|
multiply(n,n) |
square(n) |
printSquare(n) |
- Waits for CallStack to be clear
- But, higher priority than Callback Queue ...