오류 및 예외 처리 오류를 잡아내서 코드를 중지하거나 중단되지 않도록 하는 역할을 한다.
try { //오류 발생 코드가 중단되지 않고 hello.toUpperCase(); }catch(e) { //catch문에 있는 코드 실행 console.log(e); // hello is not defined } //try catch문 이후에 코드도 정상적으로 실행 console.log('hi') // hi