EvalError

EvalError 객체는 전역 eval() 함수에 관한 오류를 나타냅니다. 이 예외는 JavaScript에 의해 더 이상 발생하지 않지만 EvalError 객체는 하위 호환성을 위해 남아있습니다.

Constructor

EvalError() (en-US)

Creates a new EvalError object.

Instance properties

EvalError.prototype.message

Error message.

EvalError.prototype.name

Error name. Inherited from Error.

EvalError.prototype.fileName

Path to file that raised this error. Inherited from Error.

EvalError.prototype.lineNumber

Line number in file that raised this error. Inherited from Error.

EvalError.prototype.columnNumber

Column number in line that raised this error. Inherited from Error.

EvalError.prototype.stack (en-US)

Stack trace. Inherited from Error.

예제

EvalError는 현재 ECMAScript 사양에서 사용되지 않으므로 런타임에 의해 throw되지 않습니다. 그러나 개체 자체는 이전 버전의 사양과의 하위 호환성을 유지합니다.

Creating an EvalError

js
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
ECMAScript Language Specification
# sec-native-error-types-used-in-this-standard-evalerror

브라우저 호환성

BCD tables only load in the browser

같이 보기