4.html 609 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. 同步先行 异步靠后
  13. 同步按照顺序调用
  14. */
  15. console.log('start')
  16. const fn = () => {
  17. return new Promise((resolve, reject) => {
  18. console.log(1)
  19. resolve(2)
  20. })
  21. }
  22. console.log(3)
  23. fn().then(res => {
  24. console.log(res)
  25. })
  26. console.log('end')
  27. </script>
  28. </body>
  29. </html>