Skip to content

Commit 95fd721

Browse files
committed
docs(async): fix general
1 parent ee780f7 commit 95fd721

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

docs/async/general.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,24 @@ function final(value) {
156156
console.log('完成: ', value);
157157
}
158158

159-
async(1, function(value){
160-
async(value, function(value){
161-
async(value, function(value){
162-
async(value, function(value){
163-
async(value, function(value){
164-
async(value, final);
159+
async(1, function (value) {
160+
async(2, function (value) {
161+
async(3, function (value) {
162+
async(4, function (value) {
163+
async(5, function (value) {
164+
async(6, final);
165165
});
166166
});
167167
});
168168
});
169169
});
170+
// 参数为 1 , 1秒后返回结果
171+
// 参数为 2 , 1秒后返回结果
172+
// 参数为 3 , 1秒后返回结果
173+
// 参数为 4 , 1秒后返回结果
174+
// 参数为 5 , 1秒后返回结果
175+
// 参数为 6 , 1秒后返回结果
176+
// 完成: 12
170177
```
171178

172179
上面代码中,六个回调函数的嵌套,不仅写起来麻烦,容易出错,而且难以维护。

0 commit comments

Comments
 (0)