Skip to content

Commit 8d46f3b

Browse files
yygmindYuChengKai
authored andcommitted
change await description in JS_en
1 parent 8af0e15 commit 8d46f3b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

JS/JS-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ console.log('1', a) // -> '1' 1
12911291
You may have doubts about the above code, here we explain the principle:
12921292
12931293
- First the function `b` is executed. The variable `a` is still 0 before execution `await 10`, Because the `Generators` are implemented inside `await` and `Generators` will keep things in the stack, so at this time `a = 0` is saved
1294-
- Because `await` is an asynchronous operation, `console.log('1', a)` will be executed first.
1294+
- Because `await` is an asynchronous operation, it will immediately return a `pending` state `Promise` object when it encounter `await`, and temporarily returning control of the execution code, so that the code outside the function can continue to be executed. `console.log('1', a)` will be executed first.
12951295
- At this point, the synchronous code is completed and asynchronous code is started. The saved value is used. At this time, `a = 10`
12961296
- Then comes the usual code execution
12971297

0 commit comments

Comments
 (0)