Answer the question
In order to leave comments, you need to log in
Where exactly are asynchronous event handlers registered?
in articles about the event loop they write that event handlers are registered in the environment, but they don’t really explain and don’t go deep, as I understand it in my case (Web) this means in the browser, but where in the browser? if there is one thread in js, then how does setTimeout count time in parallel with execution before adding it to the queue?
Answer the question
In order to leave comments, you need to log in
setTimeout doesn't count anything, it adds the task to the scheduler.
Did you read this? https://learn.javascript.ru/settimeout-setinterval
More about event loop
For example here is the code:
console.log("Hello world")
setTimeout(() => console.log("Hello timeout"), 50)
console.log("Hello JS")
console.log("Hello world")
console.log("Hello JS")
console.log("Hello timeout")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question