You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/10-error-handling/1-try-catch/1-finally-or-code-after/solution.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
차이점은 함수 내부의 코드를 보면 분명해집니다.
2
2
3
-
`try..catch`에서 '빠져나오게 하는' 코드가 있다면 함수의 행동이 달라집니다.
3
+
`try..catch`에 '빠져나오게 하는' 코드가 있다면 함수의 행동이 달라집니다.
4
4
5
5
아래 예시와 같이 `try..catch` 내부에 `return`이 있을 때가 대표적인 예입니다. `finally` 절은 `return`문을 통해 `try..catch`를 빠져나가는 경우를 포함하여 `try..catch`가 종료되는 *모든* 상황에서 실행됩니다. `try..catch`가 종료되었지만, 함수 호출 코드가 제어권을 갖기 직전에 실행되죠.
6
6
@@ -30,7 +30,7 @@ function f() {
30
30
thrownewError("에러 발생!");
31
31
} catch (e) {
32
32
// ...
33
-
if("can't handle the error") {
33
+
if("에러를 핸들링 할 수 없다면") {
34
34
*!*
35
35
throw e;
36
36
*/!*
@@ -44,4 +44,4 @@ function f() {
44
44
f(); // cleanup!
45
45
```
46
46
47
-
이렇게 `finally` 절을 붙여주면 초기화가 보장됩니다. 작업 내역을 초기화해주는 코드를 단순히 `f`의 끝에 붙였다면, 위 예시와 같은 상황에선, 초기화 코드가 실행되지 않습니다.
47
+
이렇게 `finally` 절을 붙여줘야 초기화가 보장됩니다. 작업 내역을 초기화해주는 코드를 단순히 `f`의 끝에 붙였다면, 위와 같은 상황일 때 초기화 코드가 실행되지 않습니다.
0 commit comments