Skip to content

Commit e468cab

Browse files
committed
Update
1 parent 2a21078 commit e468cab

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,27 @@ console.log(300); // step2
728728
* 执行最后一行打印300
729729
* 待所有程序执行完,处于空闲状态时,会立马看有没有暂存起来的要执行
730730
* 发现暂存起来的`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+
setTimeout(function () {
744+
console.log(4);
745+
},1000)
746+
console.log(5);
747+
```
748+
* 前端使用异步的场景有哪些
749+
* 定时任务:`setTimeout,setInverval`
750+
* 网络任务:`ajax`请求,动态`<img>`加载
751+
* 事件绑定
731752
---
732753

733754
### JSDemo JS小程序

0 commit comments

Comments
 (0)