The JavaScript language execution environment is "single thread"
Only one task can be completed at a time. If you have multiple tasks, you must queue, complete the previous task, and then perform the latter task
The JavaScript language divides the execution pattern of a task into two types: synchronous (synchronous) and asynchronous (asynchronous)
"Asynchronous mode" is completely different, each task has one or more callback functions (callback), after the end of the previous task, not after the execution of a task, but the execution of the callback function, the latter task is not equal to the end of the previous task is executed, so the order of execution of the program is inconsistent with the order of the task, Asynchronous.
4 Ways to Program "asynchronous mode"
First, the callback function
Second, event monitoring
Third, publish/Subscribe
Iv. promises objects
JavaScript Asynchronous Programming asynchronous Js:callbacks, Listeners, Control Flow Libs and Promises