Webcourse/15-面试题积累/异步.md

36 lines
452 B
Markdown
Raw Normal View History

2018-03-22 11:54:37 +08:00
## 面试题
### 20180321面试题
```javascript
console.log(1);
setTimeout(function () {
console.log(2);
}, 1000);
setTimeout(function () {
console.log(3);
}, 0);
console.log(4);
```
2018-03-23 17:05:32 +08:00
### 20180321面试题
```javascript
var arr = [1, 2, 3];
for (var i = 0; i < arr.length; i++) {
setTimeout(function () {
console.log(i);
}, 0);
}
```
打印结果333