JS induction of async await

 

await for waiting for a Promise objects , it can only be used in a function async

[the return_value] = the await expression The 

expression: a Promise object or to wait any value 

Return Value: returns the processing result Promise object. If you wait Promise is not an object, it returns the value itself

https://www.cnblogs.com/rogerwu/p/10784236.html

https://www.cnblogs.com/CandyManPing/p/9384104.html

 

JS sleep函数


 sleep(ms) {
      return resolve => {
        setTimeout(resolve, ms)
      }
    }

    sleep(ms) {
      return new Promise(resolve => {
        setTimeout(resolve, ms)
      })
    }

 

Guess you like

Origin www.cnblogs.com/yum777/p/12091907.html