diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/global_objects/error/tosource | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/error/tosource')
| -rw-r--r-- | files/ja/web/javascript/reference/global_objects/error/tosource/index.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/error/tosource/index.html b/files/ja/web/javascript/reference/global_objects/error/tosource/index.html new file mode 100644 index 0000000000..52085a0de4 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/error/tosource/index.html @@ -0,0 +1,58 @@ +--- +title: Error.prototype.toSource() +slug: Web/JavaScript/Reference/Global_Objects/Error/toSource +tags: + - Error + - JavaScript + - Method + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Error/toSource +--- +<div>{{JSRef}} {{non-standard_header}}</div> + +<p><code><strong>toSource()</strong></code> メソッドは、同じエラーを評価できるコードを返します。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate"><var>e</var>.toSource()</pre> + +<h3 id="Return_value" name="Return_value">返値</h3> + +<p>エラーのソースコードを含む文字列。</p> + +<h2 id="Description" name="Description">解説</h2> + +<h3 id="Using_toSource">Using toSource</h3> + +<p>{{jsxref("Error")}} インスタンス (<em><a href="/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types">NativeErrors</a></em> を含む) の <code>toSource</code> メソッドを呼び出すと、エラーのソースコードを含む文字列を返します。この文字列を評価して (ほぼ) 等しいオブジェクトを生成できます。通常、この文字列には、{{jsxref("Error")}} コンストラクターの構造に続けて下記のようにソースが含まれます。</p> + +<pre class="brush: js notranslate">(new<em>name</em>(<em>message</em> ,<em>fileName</em>,<em>lineNumber</em>)) +</pre> + +<p>これらの属性は、それぞれのエラーインスタンスの各属性に相当します。</p> + +<div class="note"> +<p><strong>注:</strong> この文字列の生成で <code>toSource</code> メソッドにより使用されるプロパティは変更可能であり、エラーインスタンスの生成に使用された関数、または実際にエラーが起こった場所のファイル名、行番号を正確に反映しない可能性があることに注意してください。</p> +</div> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<p>仕様の一部ではありません。</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Error.toSource")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Error.prototype.fileName")}}</li> + <li>{{jsxref("Error.prototype.lineNumber")}}</li> + <li>{{jsxref("Error.prototype.message")}}</li> + <li>{{jsxref("Error.prototype.name")}}</li> + <li>{{jsxref("Object.prototype.toSource()")}}</li> +</ul> |
