Mastered in EVENT LOOP
setTimeout(() => { console.log('I am the last one') }, 0); function count () { for (var i = 0; i < 5; i++) { ((i) => setTimeout(() => console.log(i), 1000 * i))(i) } } (async () => { console.log('Let\'s count') await count() await 1; console.log('What are you doing? ') })() Promise.resolve().then(async () => { await new Promise((resolve) => { console.log('I am in a nest promise') resolve( (() => setTimeout(() => Promise.resolve('Do you think I will get there? ').then(res => { console.log(res) }), 0))() ) }).then(() => { console.log('Absolutely') }) }) console.log('Script start') setTimeout(() => { console.log('Script end') }, 2000)
What about your answer :)
相关推荐
89500297 2020-05-05
sfkong 2020-08-02
delmarks 2020-04-09
gjcxywwx 2019-11-04
前端开发Kingcean 2019-10-22
Magicsoftware 2019-10-19
xuewenke 2012-02-05
jiangbo0 2019-09-08
85403263 2019-07-01
codable 2019-07-01
梦秋雨 2019-07-01
87241940 2019-06-30
83251242 2019-06-30
85281643 2019-06-29
whynotgonow 2019-06-29