- JS engine is a program that executes JS code. It consists of:
- Memory Heap (stores vars, objects, etc)
- Call Stack (records where in the program we are)
- Web APIs (timers, AJAX, DOM, promises)
- Event Loop (monitors msg queue and call stack)
Popular JS engines:
- V8 (Chrome, Node.js)
- SpiderMonkey (Firefox)
- Chakra (Edge)
- JavaScriptCore (Safari)
V8 is the most popular JS engine, used in Chrome and Node.js. It compiles JS code to machine code, which is faster than interpreting.
V8 has 2 compilers:
- Full Compiler (optimizes code) nam
- Ignition (interprets code)