Skip to content

Commit

Permalink
docs(async): edit top-level await
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Jul 6, 2022
1 parent 7d22df8 commit 7d030c6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ const data = await fetch('https://api.example.com');

上面代码中,`await`命令独立使用,没有放在 async 函数里面,就会报错。

[ES2022](https://github.com/tc39/proposal-top-level-await) 开始,允许在模块的顶层独立使用`await`命令,使得上面那行代码不会报错了。它的主要目的,是使用`await`解决模块异步加载的问题。
[ES2022](https://github.com/tc39/proposal-top-level-await) 开始,允许在模块的顶层独立使用`await`命令,使得上面那行代码不会报错了。它的主要目的是使用`await`解决模块异步加载的问题。

```javascript
// awaiting.js
Expand Down

0 comments on commit 7d030c6

Please sign in to comment.