We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a21078 commit e468cabCopy full SHA for e468cab
README.md
@@ -728,6 +728,27 @@ console.log(300); // step2
728
* 执行最后一行打印300
729
* 待所有程序执行完,处于空闲状态时,会立马看有没有暂存起来的要执行
730
* 发现暂存起来的`setTimeout`中的函数无需等待时间,就立即来过来执行
731
+#### 解答:异步与单线程
732
+* 同步和异步的区别是什么?分别举一个同步和异步的例子
733
+ * 同步会阻塞代码执行,而异步不会
734
+ * `alert`是同步,`setTimeout`是异步
735
+* 一个关于setTimeout的笔试题
736
+* 可以说`setTimeout`是等待页面加载完毕后,在进行加载
737
+```JavaScript
738
+console.log(1);
739
+setTimeout(function () {
740
+ console.log(2);
741
+},0)
742
+console.log(3);
743
744
+ console.log(4);
745
+},1000)
746
+console.log(5);
747
+```
748
+* 前端使用异步的场景有哪些
749
+ * 定时任务:`setTimeout,setInverval`
750
+ * 网络任务:`ajax`请求,动态`<img>`加载
751
+ * 事件绑定
752
---
753
754
### JSDemo JS小程序
0 commit comments