Skip to content

Commit 6b48e1c

Browse files
authored
Update task.md
1 parent 7686d88 commit 6b48e1c

File tree

1 file changed

+6
-6
lines changed
  • 1-js/08-error-handling/1-try-catch/1-finally-or-code-after

1 file changed

+6
-6
lines changed

1-js/08-error-handling/1-try-catch/1-finally-or-code-after/task.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Finally or just the code?
5+
# `finally` 中执行,还是在直接放在代码后面
66

7-
Compare the two code fragments.
7+
比较下面两个代码片段。
88

9-
1. The first one uses `finally` to execute the code after `try..catch`:
9+
1. `finally` 执行 `try..catch` 之后的代码:
1010

1111
```js
1212
try {
@@ -19,7 +19,7 @@ Compare the two code fragments.
1919
*/!*
2020
}
2121
```
22-
2. The second fragment puts the cleaning right after `try..catch`:
22+
2. 第二个代码片段,把清空工作空间的代码放在 `try..catch` 之后,但并不包裹在 `finally` 里面。
2323

2424
```js
2525
try {
@@ -33,6 +33,6 @@ Compare the two code fragments.
3333
*/!*
3434
```
3535

36-
We definitely need the cleanup after the work has started, doesn't matter if there was an error or not.
36+
我们只是需要在代码执行完之后,清除工作空间,而不管是不是在执行的过程中遇到异常。
3737

38-
Is there an advantage here in using `finally` or both code fragments are equal? If there is such an advantage, then give an example when it matters.
38+
那么,是用 `finally` 好呢还是两种方式都一样?如果哪种更好,请举例说明在什么情况下它会更好?

0 commit comments

Comments
 (0)