EvalError
EvalError 객체는 전역 eval() 함수에 관한 오류를 나타냅니다. 이 예외는 JavaScript에 의해 더 이상 발생하지 않지만 EvalError 객체는 하위 호환성을 위해 남아있습니다.
구문
new EvalError([message[, fileName[, lineNumber]]])매개변수
messageOptional- 인간이 읽을 수 있는 오류 설명.
fileNameOptional- 예외의 원인이 된 코드를 포함하는 파일의 이름.
lineNumberOptional- 예외를 발생시킨 코드의 행 번호.
속성
EvalError.prototype(en-US)- EvalError 객체에 속성을 추가할 수 있습니다.
메서드
전역 EvalError에는 자체 메서드가 없지만 프로토 타입 체인을 통해 일부 메서드를 상속받습니다.
EvalError 인스턴스
Properties
{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype', 'Properties')}}
Methods
{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError/prototype', 'Methods')}}
예제
EvalError는 현재 ECMAScript 사양에서 사용되지 않으므로 런타임에 의해 throw되지 않습니다. 그러나 개체 자체는 이전 버전의 사양과의 하위 호환성을 유지합니다.
Creating an EvalError
try {
throw new EvalError('Hello', 'someFile.js', 10);
} catch (e) {
console.log(e instanceof EvalError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "EvalError"
console.log(e.fileName); // "someFile.js"
console.log(e.lineNumber); // 10
console.log(e.columnNumber); // 0
console.log(e.stack); // "@Scratchpad/2:2:9\n"
}
명세
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 3rd Edition (ECMA-262) | Standard | Initial definition. |
| ECMAScript 5.1 (ECMA-262) The definition of 'EvalError' in that specification. |
Standard | Not used in this specification. Present for backward compatibility. |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'EvalError' in that specification. |
Standard | Not used in this specification. Present for backward compatibility. |
| ECMAScript (ECMA-262) The definition of 'EvalError' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser