Why doesn't Javascript have a concept of timers?

Every once in a while, I hear about how setTimeout, setInterval, etc are not native to Javascript, but are functions that browsers and node choose to implement on top of Javascript. Javascript doesn't have the concept of timers and delays.

Is there any particular reason for this? Or is that just how things are currently in the spec, but it could change in the future?

There is an ideological reason for it (TL;DR: timers are a runtime-specific concept and not very well suited for a general-purpose embedded engine with minimal awareness of its surrounding execution environment), but I'll defer to someone on TC39 to provide more complete background.

Just for full disclosure, I disagree with them on the specific point of timers, but agree with the rest and have even gone as far as to push for moving the legacy HTML string methods to the WHATWG spec.

1 Like