3

I am hearing that setTimeout(), the Web API is not included in JavaScript quite often. So, if it is only Web API it is natural to think as it won't work anywhere except in the browser. So, why setTimeout is working in my terminal when I just run a plain old JS file with the node ${filename} command?

  • 1
    Check https://nodejs.org/en/docs/guides/timers-in-node/#when-i-say-so-execution-settimeout – Tanay Apr 17 '22 at 05:08
  • Thanks you! So it is Node related feature and JS have nothing to do with that yes? Is the statement JS do not have `setTimeout` right? – Ahmad Shahbalayev Apr 17 '22 at 09:09

1 Answers1

4

The browser and node.js both have a global setTimeout function, but the return types are different between the two.

dlannoye
  • 1,746
  • 19
  • 19