123456789101112131415161718192021222324252627282930313233 |
- <!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>
- // alert(1);
- // console.log("hello");
- // 任务队列 事件循环 event loop
- // 异步方法 setTimeout setInterval
- // 如果js发现异步方法无论等多久都会将它放到异步的任务队列当中,先执行同步代码
- // setTimeout(function(){
- // console.log("world");
- // },0);
- // console.log("hello");
- function foo(timer,fun){
- setTimeout(function(){
- fun();
- },timer)
- }
- foo(2000,function(){
- console.log("world");
- });
- </script>
- </body>
- </html>
|