코드팩토리 JS

12. try catch

박성하하 2025. 12. 26. 14:51
728x90
반응형
/**
 * try...catch
 *
 * 1) 발생시킬때 -> 던진다고한다. (throw)
 * 2) 명시적으로 인지할때 -> 잡는다고 한다. (catch)
 */
function runner() {
    try {
        console.log('Hello');

        // throw new Error('큰 문제가 생겼습니다!');

        console.log('Code Factory');
    } catch (e) {
        console.log('---catch---');
        console.log(e);
    } finally {
        console.log('---finally---');
    }
}
runner();
728x90
반응형

'코드팩토리 JS' 카테고리의 다른 글

14. Getter and Setter  (0) 2025.12.26
13. class  (0) 2025.12.26
11. copy by value and reference  (0) 2025.12.22
10.object  (0) 2025.12.22
9. must know array functions  (0) 2025.12.17