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
"use strict";// 전역 변수 mistypedVariable 이 존재한다고 가정mistypedVaraible=17;// 변수의 오타때문에 이 라인에서 ReferenceError 를 발생시킴
예외를 발생시킨다.
"use strict";// 쓸 수 없는 프로퍼티에 할당varundefined=5;// TypeError 발생varInfinity=5;// TypeError 발생// 쓸 수 없는 프로퍼티에 할당varobj1={};Object.defineProperty(obj1,"x",{value: 42,writable: false});obj1.x=9;// TypeError 발생// getter-only 프로퍼티에 할당varobj2={getx(){return17;}};obj2.x=5;// TypeError 발생// 확장 불가 객체에 새 프로퍼티 할당varfixed={};Object.preventExtensions(fixed);fixed.newProp="ohai";// TypeError 발생
삭제할 수 없는 프로퍼티를 삭제하려 할 때 예외를 발생시킨다.
"use strict";
delete Object.prototype; // TypeError 발생
중복된 파라미터 이름은 구문 에러를 발생시킨다.
functionsum(a,a,c){// !!! 구문 에러"use strict";returna+b+c;// 코드가 실행되면 잘못된 것임}
엄격 모드
엄격 모드는 구문과 런타임 동작을 변경한다.
실수를 에러로
실수로 글로벌 변수를 생성하는 것을 불가능하게 한다.
예외를 발생시킨다.
삭제할 수 없는 프로퍼티를 삭제하려 할 때 예외를 발생시킨다.
중복된 파라미터 이름은 구문 에러를 발생시킨다.
0
을 붙여서 사용하는 8진법 숫자 리터럴을 금지한다.원시값에 프로퍼티를 설정하는것을 금지한다.
변수 사용 단순화
with
를 사용하지 못하게 한다.eval
은 새로운 변수를 주위 스코프에 추가하지 않는다.delete
를 사용하지 못하게 한다.eval
,arguments
단순화eval
,arguments
는 언어 문법에 바운드되거나 할당될 수 없다. (변수, 함수, 파라미터 이름 등으로 사용될 수 없다.)arguments
객체가 생성한 프로퍼티를 alias 하지 않는다. (첫번째 파라미터에 값을 할당하면arguments[0]
이 변경되던 동작이 없어진다.)arguments.callee
를 지원하지 않는다.JavaScript 보안
Javascript 보안 내용 참고
예약어
미래에 사용될 수 있는 몇가지 키워드들을 예약어로 지정한다.
The text was updated successfully, but these errors were encountered: