JS执行队列

Tutorial: DOM操作 Category: JS Published: 2026-04-07 13:58:26 Views: 20 Likes: 0 Comments: 0

JS 执行队列

<!DOCTYPE html>
<html lang="en">
  <head></head>

  <body>
    <script>
      // 第一个问题 1 2 3
      // console.log(1);
      // setTimeout(function () {
      //   console.log(3);
      // }, 1000);
      // console.log(2);

      // 2. 第二个问题 1 2 3
      // console.log(1);
      // setTimeout(function () {
      //   console.log(3);
      // }, 0);
      // console.log(2);

      // 3. 第三个问题 1 2 3 | click
      console.log(1);
      document.onclick = function () {
        console.log("click");
      };
      console.log(2);
      setTimeout(function () {
        console.log(3);
      }, 3000);
    </script>
  </body>
</html>