Error.prototype.lineNumber
非標準: この機能は標準ではなく、標準化の予定もありません。公開されているウェブサイトには使用しないでください。ユーザーによっては使用できないことがあります。実装ごとに大きな差があることもあり、将来は振る舞いが変わるかもしれません。
lineNumber
プロパティは、このエラーを起こしたファイル内の行番号が入ります。
例
lineNumber の使用
js
var e = new Error("Could not parse input");
throw e;
console.log(e.lineNumber); // 2
error イベントを使用した他の例
js
window.addEventListener("error", function (e) {
console.log(e.lineNumber); // 5
});
var e = new Error("入力を解釈できません");
throw e;
これは標準の機能ではなく、幅広く対応されていません。下記のブラウザーの互換性の表をご覧ください。
仕様書
仕様の一部ではありません。
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lineNumber |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Non-standard. Check cross-browser support before using.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.