Web/06-JavaScript基础:异步编程/14-Promise常见面试题.md
2023-07-11 21:03:41 +08:00

28 lines
440 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 这些代码的打印结果是什么?
想要考察一个人对 Promise 的掌握程度,就让他看看这些代码的打印结果是什么。
**例1**resolve()多次
```js
const promise = new Promise((resolve, reject) => {
resolve();
resolve();
});
promise
.then(res => {
console.log('成功的回调');
})
.catch(err => {
console.log('失败的回调');
});
```
打印结果:
```
成功的回调
```