blob: fde9526dbc55d013b965e93ae8f1fc4aae40b9f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
---
title: Error.prototype.lineNumber
slug: Web/JavaScript/Reference/Global_Objects/Error/lineNumber
tags:
- Error
- JavaScript
- Property
- Reference
translation_of: Web/JavaScript/Reference/Global_Objects/Error/lineNumber
---
<div>{{JSRef}} {{non-standard_header}}</div>
<p><code><strong>lineNumber</strong></code> プロパティは、このエラーを起こしたファイル内の行番号が入ります。</p>
<h2 id="Examples" name="Examples">例</h2>
<h3 id="Using_lineNumber" name="Using_lineNumber">lineNumber の使用</h3>
<pre class="brush: js notranslate">var e = new Error('Could not parse input');
throw e;
console.log(e.lineNumber) // 2
</pre>
<h3 id="Alternative_example_using_error_event" name="Alternative_example_using_error_event">error イベントを使用した他の例</h3>
<pre class="brush: js notranslate">window.addEventListener('error', function(e) {
console.log(e.lineNumber); // 5
});
var e = new Error('入力を解釈できません');
throw e;
</pre>
<p>これは標準の機能ではなく、幅広く対応されていません。下記のブラウザーの互換性の表をご覧ください。</p>
<h2 id="Specifications" name="Specifications">仕様書</h2>
<p>仕様の一部ではありません。</p>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<div>
<p>{{Compat("javascript.builtins.Error.lineNumber")}}</p>
</div>
<h2 id="See_also" name="See_also">関連情報</h2>
<ul>
<li>{{jsxref("Error.prototype.stack")}}</li>
<li>{{jsxref("Error.prototype.columnNumber")}}</li>
<li>{{jsxref("Error.prototype.fileName")}}</li>
</ul>
|