HTML: Markup language
CSS: Styling language
JavaScript: Scripting language
Web APIs: Programming interfaces
All web technology
Learn web development
Discover our tools
Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
View in English Always switch to English
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
ReferenceError オブジェクトは、現在のスコープに存在しない(あるいはまだ初期化されていない)変数が参照されたときのエラーを表します。
ReferenceError
ReferenceError はシリアライズ可能オブジェクトなので、 structuredClone() で複製したり、ワーカー間で postMessage() を使用してコピーしたりすることができます。
structuredClone()
postMessage()
ReferenceError は Error のサブクラスです。
Error
ReferenceError()
新しい ReferenceError オブジェクトを生成します。
親である Error から継承したプロパティもあります。
これらのプロパティは ReferenceError.prototype で定義されており、すべての ReferenceError インスタンスで共有されます。
ReferenceError.prototype
ReferenceError.prototype.constructor
このインスタンスオブジェクトを作成したコンストラクター関数。 ReferenceError インスタンスの場合、初期値は ReferenceError コンストラクタです。
ReferenceError.prototype.name
エラー型の名前を表します。 ReferenceError.prototype.name の初期値は "ReferenceError" です。
"ReferenceError"
親である Error から継承したメソッドもあります。
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); // このエラーのスタック }
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); // このエラーのスタック }
Enable JavaScript to view this browser compatibility table.