Strict

    [JavaScript] strict 모드

    strict 모드란? ECMAScript 5에서 처음으로 소개된 strict 모드는 자바스크립트 코드에 더욱 엄격한 오류 검사를 적용해 준다. strict 모드는 스크립트나 함수의 맨 처음에 "use strict" 지시어를 사용하여 선언할 수 있다. "use strict" // 전체 스크립트를 strict 모드로 설정함. try { num = 3.14; // 선언되지 않은 변수를 사용했기 때문에 오류를 발생시킴. } catch (ex) { document.getElementById("text").innerHTML = ex.name + " "; document.getElementById("text").innerHTML += ex.message; } 실행 결과 ReferenceError num is not ..