JS (asynchronous)

Question 1. What is the difference between synchronous and asynchronous, try an example

Topic 2. About setTimeout

Topic 3. What are the scenarios where the front end uses asynchronous

 

Knowledge point

1. What is asynchronous

Result: 100 300 200

Asynchronous result: 100 300 (do not wait) 200

Synchronization result: 100 200 (waiting) 300    (will block the running of the following code)

Contrast sync

Result (sync): 100 200 (click to confirm) 300  

When do you need async

1. In a situation where waiting may occur

2. During the waiting process, the program cannot be blocked like an alert.

In summary, all "await cases" need to be asynchronous

Second, the front-end uses asynchronous scenarios

3. Asynchronous and single-threaded

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325293272&siteId=291194637