fe-notes
fe-notes copied to clipboard
JavaScript 中的任务
我们经常会看到同步任务和异步任务的文章,而且对这些概念的认知都根深蒂固了,但什么是任务呢?下面是一段对任务的描述:
A task is any JavaScript code which is scheduled to be run by the standard mechanisms such as initially starting to run a program, an event callback being run, or an interval or timeout being fired. ... An event fires, adding the event's callback function to the task queue.
任务是由标准机制安排运行的任何 JavaScript 代码,如最初开始运行程序,事件回调被运行,或间隔或超时被触发。一个事件被触发,将事件的回调函数添加到任务队列中。