12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- const p = new Promise((resolve, reject) => {
- resolve(0)
- console.log(1)
- setTimeout(() => {
- console.log('timerStart')
- resolve('resolve')
- console.log('timerEnd')
- setTimeout(() => {
- console.log('aa')
- reject(10)
- }, 10)
- }, 0)
- console.log(2)
- })
- p.then((res) => {
- console.log(res)
- // setTimeout(()=>{
- // console.log('ttttimer')
- // },0)
- const promise4 = Promise.resolve().then(() => {
- console.log('promise1')
- })
- })
- console.log('end')
- //1 2 end 0 timerstart timerend aa ttt
- //1 2 end 0 timerstart timerend ttt aa
- //1 2 end 0 tttt timerstart timerend aa
- </script>
- </body>
- </html>
|