2.html 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. // 说出下面代码的输出
  12. async function async1() {
  13. console.log('async1 start');
  14. await async2();
  15. console.log('async1 end');
  16. }
  17. async function async2() {
  18. console.log('async2');
  19. /* return new Promise((resolve, reiejct) => {
  20. resolve()
  21. }) */
  22. /* Promise1.then((Promise2)=>{
  23. Promise2.then(()=>{
  24. console.log()
  25. })
  26. }) */
  27. }
  28. console.log('script start')
  29. async1();
  30. new Promise(function (resolve) {
  31. console.log('promise1');
  32. resolve();
  33. }).then(function () {
  34. console.log('promise2');
  35. });
  36. console.log('script end')
  37. //sc start => asy1 start => asy2 => p1 => sc end => p2 => asy1 end
  38. </script>
  39. </body>
  40. </html>