- Node, bun là JS runtime
| Feature | JavaScript Engine 🏎 | JavaScript Runtime 🌍 |
|---|---|---|
| Definition | A program that parses, compiles, and executes JavaScript code | The complete environment that allows JavaScript to run (including the engine + APIs) |
| Purpose | Converts JS code into machine code and runs it | Provides everything JS needs to run (I/O, APIs, etc.) |
| Includes | Just the JS execution engine | JS engine + Web APIs (browser) or system APIs (Node.js, Bun) |
| Example Engines | 🔹 V8 (Chrome, Node.js) 🔹 SpiderMonkey (Firefox) 🔹 JavaScriptCore (Safari) | 🔹 Browser (Chrome, Firefox, Safari) 🔹 Node.js 🔹 Deno 🔹 Bun |
| Runs Inside | A runtime environment like a browser or Node.js | A browser or standalone runtime (Node.js, Bun, Deno) |
- A JavaScript engine is a program that takes raw JavaScript code, compiles it into machine code, and executes it.
✅ JavaScript running in the browser runtime → Client-side code
✅ JavaScript running in the server runtime (Node.js, Bun) → Server-side code