A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError below:

ReferenceError - JavaScript | MDN

ReferenceError

Baseline Widely available *

ReferenceError オブジェクトは、現在のスコープに存在しない(あるいはまだ初期化されていない)変数が参照されたときのエラーを表します。

ReferenceError はシリアライズ可能オブジェクトなので、 structuredClone() で複製したり、ワーカー間で postMessage() を使用してコピーしたりすることができます。

ReferenceError は Error のサブクラスです。

コンストラクター
ReferenceError()

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

インスタンスプロパティ

親である Error から継承したプロパティもあります。

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

ReferenceError.prototype.constructor

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

ReferenceError.prototype.name

エラー型の名前を表します。 ReferenceError.prototype.name の初期値は "ReferenceError" です。

インスタンスメソッド

親である Error から継承したメソッドもあります。

例 ReferenceError の捕捉
try {
  let a = undefinedVariable;
} catch (e) {
  console.log(e instanceof ReferenceError); // true
  console.log(e.message); // "undefinedVariable is not defined"
  console.log(e.name); // "ReferenceError"
  console.log(e.stack); // このエラーのスタック
}
ReferenceError の生成
try {
  throw new ReferenceError("Hello");
} catch (e) {
  console.log(e instanceof ReferenceError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "ReferenceError"
  console.log(e.stack); // このエラーのスタック
}
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4