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

SyntaxError - JavaScript | MDN

SyntaxError

Baseline Widely available *

SyntaxError オブジェクトは、構文的に不正なコードを解釈しようとした場合のエラーを表します。これは、 JavaScript エンジンが、コードを解析中に言語の構文に従わないトークンまたはトークンの順序に遭遇した場合に発生します。

コンストラクター
SyntaxError()

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

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

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

SyntaxError.prototype.name

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

SyntaxError.prototype.fileName

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

SyntaxError.prototype.lineNumber

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

SyntaxError.prototype.columnNumber

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

SyntaxError.prototype.stack

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

例 SyntaxError のキャッチ
try {
  eval("hoo bar");
} catch (e) {
  console.error(e instanceof SyntaxError);
  console.error(e.message);
  console.error(e.name);
  console.error(e.fileName);
  console.error(e.lineNumber);
  console.error(e.columnNumber);
  console.error(e.stack);
}
SyntaxError の生成
try {
  throw new SyntaxError("Hello", "someFile.js", 10);
} catch (e) {
  console.error(e instanceof SyntaxError); // true
  console.error(e.message); // Hello
  console.error(e.name); // SyntaxError
  console.error(e.fileName); // someFile.js
  console.error(e.lineNumber); // 10
  console.error(e.columnNumber); // 0
  console.error(e.stack); // @debugger eval code:3:9
}
仕様書 ブラウザーの互換性 関連情報

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