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/TypeError below:

TypeError - JavaScript | MDN

TypeError

Baseline Widely available *

TypeError オブジェクトは、演算が実行できなくなった時の新しいエラーを表します。特に値が期待された型ではなかった場合です (ただし、それに限りません)。

TypeError は以下のような場合に発生します。

コンストラクター
TypeError()

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

インスタンスプロパティ
TypeError.prototype.message

エラーメッセージです。 ECMA-262 において TypeError は自身の message プロパティを提供するべきとされていますが、 SpiderMonkey では Error.prototype.message を継承しています。

TypeError.prototype.name

エラー名です。 Error から継承しています。

TypeError.prototype.fileName

このエラーが発生したファイルのパスです。 Error から継承しています。

TypeError.prototype.lineNumber

このエラーが発生したファイル内の行番号です。 Error から継承しています。

TypeError.prototype.columnNumber

このエラーが発生した行内の桁番号です。 Error から継承しています。

TypeError.prototype.stack

スタックトレースです。 Error から継承しています。

例 TypeError のキャッチ
try {
  null.f();
} catch (e) {
  console.log(e instanceof TypeError); // true
  console.log(e.message); // "null has no properties"
  console.log(e.name); // "TypeError"
  console.log(e.fileName); // "Scratchpad/1"
  console.log(e.lineNumber); // 2
  console.log(e.columnNumber); // 2
  console.log(e.stack); // "@Scratchpad/2:2:3\n"
}
TypeError の生成
try {
  throw new TypeError("Hello", "someFile.js", 10);
} catch (e) {
  console.log(e instanceof TypeError); // true
  console.log(e.message); // "Hello"
  console.log(e.name); // "TypeError"
  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"
}
仕様書 ブラウザーの互換性 関連情報

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