The asynchronous JavaScript execution

The computer program execution is divided into synchronous and asynchronous implementation of
the so-called synchronous execution, is the order of the normal computer programs executing
sequence control statements from top to bottom, from left to right
branch control statements if switch
control statement for loop, while, do ... while ()
so-called asynchronous execution, implementation is a special program
setInterval setTimeout
binding the onclick event ...
ajax request
so-called asynchronous execution procedure
1. All asynchronous execution of the program, the program will be executed after synchronization, and then perform
2 asynchronous program execution sequence, if the same amount of time, to see the code sequence
different time, short time intervals before performing
execution of step procedure described:
1. the program execution starts from the first line of code
synchronization procedure executed normally 2.
3. If yes asynchronous program, temporarily performed
in the asynchronous storage pool, awaiting execution
4. after the program is finished in the synchronization procedure
the pool enables asynchronous, asynchronous to program execution
when the set time is reached, the program will perform the corresponding asynchronous
first-set given time of the first asynchronous program execution
the same time, if set by step program Order to execute
Note: You must keep in mind that asynchronous procedure must be performed after all the synchronization procedure completed

		setInterval(function(){
            console.log('我是异步执行的程序1111');
        } , 2000);
        setInterval(function(){
            console.log('我是异步执行的程序2222');
        } , 1000);
        console.log('我是同步执行的程序')

Results console output is
Here Insert Picture Description
can be seen that the first synchronization procedure is performed, and then perform asynchronous program, sequence program step depends on the time interval set itself.

Published 21 original articles · won praise 3 · Views 319

Guess you like

Origin blog.csdn.net/qq_44531034/article/details/105108115