非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

lineNumber 属性的值为抛出错误的代码在其源文件中所在的行号。

示例

使用 lineNumber

var e = new Error('Could not parse input');
throw e;
console.log(e.lineNumber) // 2

监听 error 事件的示例

window.addEventListener('error', function(e) {
  console.log(e.lineNumber); // 5
});
var e = new Error('Could not parse input');
throw e;

这不是一个标准化的属性,缺乏广泛的支持。参见下面的浏览器兼容性表格。

规范

非标准化属性。不属于任何规范。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic support
Non-standard
Chrome No support NoEdge No support NoFirefox Full support 1IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android Full support 4Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No

Legend

Full support  
Full support
No support  
No support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.

相关内容

文档标签和贡献者

标签: 
此页面的贡献者: WayneCui
最后编辑者: WayneCui,