Most developers write this code every day:
```js id="e9u2xa"
setTimeout(() => {
console.log("Hello");
}, 2000);
and assume JavaScript is responsible for the timer.
But that’s not actually true.
## The surprising reality
JavaScript engines like V8 do **not** have built-in timer functionality.
V8 only knows how to:
* parse JavaScript * compile JavaScript * execute JavaScript
That’s it.
Functions like:
* `setTimeout()` * `fetch()` * `addEventListener()` * `console.log()`
are **not provided by JavaScript itself**.
They come from the runtime environment:
* Browsers * Node.js * Native system libraries
---
# What happens when `setTimeout()` runs?
When you execute:
```js id="n5lf4v" setTimeout(callback, 2000);
Enter fullscreen mode
Exit fullscreen mode
the flow is roughly:
```text id="38dxux"
JavaScript
↓
V8 Engine
↓
Runtime Bindings
↓
Native C/C++ APIs
↓
Operating System
The runtime delegates the timer to native code.
In browsers:
* Web APIs handle timers
In Node.js:
* libuv…