There are three ways to solve the loop output problem of setTimeout
We sometimes encounter the problem of calling setTimeout in a loop to iterate over, as shown below. The output result will only be 5 6, because JavaScript is single-threaded, executed sequentially, setTimeout is an asynchronous function, it will put the timer function…