1: triggering and execution is not the same concept, the callback function of the timer must be triggered after the time of the specified delay, but not necessarily immediately , may need to wait. All JavaScript code is executed in one thread, and events such as mouse clicks and timers are only executed when the JS single-thread is idle.
2: In the browser, the JavaScript engine is event-driven, where events can be thought of as a variety of tasks that the browser assigns to it, which may originate from the currently executing block of code, such as calling settimeout (), or from the browser kernel, such as the onload (), OnClick (), onmouseover (), SetTimeOut (), SetInterval (), Ajax, and so on. From the point of view of the code, the so-called task entity is a variety of callback functions, because of the "single-threaded" reason, these tasks will be queued, one after another waiting to be processed by the engine.
JavaScript Async, Callback