123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // setTimeout(()=>{
- // console.log("hello");
- // },1000)
- // console.log("world");
- //async await 异步优化解决方案
- // async 用来表示函数是异步的
- // await 用来表示紧跟在后面的表达式需要等待结果 等待的是一个promise对象
- // async function foo(){
- // await new Promise((resolve,reject)=>{
- // setTimeout(()=>{
- // resolve()
- // console.log("hello");
- // },1000)
- // })
- // console.log("world");
- // }
-
- // foo();
-
- // let foo = () => {
- // setTimeout(()=>{
- // console.log("hello");
- // },1000)
- // console.log("world");
- // }
- // foo();
- </script>
- </body>
- </html>
|