JS JS higher order --- Why is single-threaded execution? ? ?

Outline:

 

 

【main body】

(1) how to prove JS run single-threaded?

The code above sequence results: Fn () timeout → 1111 → timeout 2222

Next, the code to make the modifications to the above

As shown in the results of the right

Then click OK to close the bomb box, and then again 1s execution timeoout 1111 , a few 1s execution timeout 2222

As can be seen from here, alert suspended time, click OK until after resuming program execution and timing

 

 Finally summarized as follows

 

 

 

 

(2) Why JS is single-threaded mode?

 

 

 

 

 

 

 

 

 

 

 

 

 

.

Guess you like

Origin www.cnblogs.com/jianxian/p/11980109.html