try catch1 자바스크립트 try catch 자바스크립트에서 에러가 발생하면 프로그램이 중지되면서 멈추는데 try catch 문법을 사용하면 try 블록에서 에러가 발생했을 때 catch 블록에서 예외 처리를 할 수 있고 finally 블록은 마지막에 무조건 실행되고 실행 중인 프로그램이 중지되지 않습니다. 사용법 try { h.toUpperCase(); } catch { console.log("error"); } finally { console.log("run"); } try { throw "exception"; } catch { console.log("error"); } finally { console.log("run"); } function f(msg) { try { console.log(msg.toUpperCase()); } catch (e.. 2023. 4. 4. 이전 1 다음