EvalError

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

EvalError オブジェクトは、グローバルの eval() 関数に関するエラーを示します。この例外はもう JavaScript からは発生しなくなっていますが、互換性のために EvalError オブジェクトが残っています。

EvalErrorシリアライズ可能オブジェクト ですので、structuredClone() でクローンされるか、postMessage() を使い ワーカー の間でコピーされます。

EvalErrorError のサブクラスです。

コンストラクター

EvalError()

新しい EvalError オブジェクトを生成します。

インスタンスプロパティ

親である {{jsxref("Error")} から継承したプロパティがあります

これらのプロパティは EvalError.prototype に定義されており、すべての EvalError インスタンスで共有されます。

EvalError.prototype.constructor

インスタンスオブジェクトを作成したコンストラクター関数。EvalError インスタンスの場合、初期値は EvalError コンストラクターです。

EvalError.prototype.name

エラー名です。EvalError.prototype.name の場合、初期値は "EvalError" です。

インスタンスメソッド

親である {{jsxref("Error")} から継承したプロパティがあります

EvalError の生成

js
try {
  throw new EvalError("Hello");
} catch (e) {
  console.log(e instanceof EvalError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "EvalError"
  console.log(e.stack); // エラースタック
}

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-native-error-types-used-in-this-standard-evalerror

ブラウザーの互換性

BCD tables only load in the browser

関連情報