SyntaxError.prototype
SyntaxError.prototype 属性表示SyntaxError构造器的原型.
描述
所有SyntaxError实例继承自 SyntaxError.prototype. 你可以使用该原型给所有实例添加属性和方法.
属性
SyntaxError.prototype.constructor创建实例的构造函数.
SyntaxError.prototype.message错误信息. 尽管 ECMA-262 指出,SyntaxError应该提供其子什么的信息属性,但在 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原型对象自身不包含任何方法,但 SyntaxError实例从原型链中继承了一些方法.
规范
Specification | Status | Comment |
|---|---|---|
ECMAScript 3rd Edition (ECMA-262) | Standard | Initial definition. |
ECMAScript 5.1 (ECMA-262)The definition of 'NativeError.prototype' in that specification. | Standard | Defined as NativeError.prototype. |
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'NativeError.prototype' in that specification. | Standard | Defined as NativeError.prototype. |
ECMAScript Latest Draft (ECMA-262)The definition of 'NativeError.prototype' in that specification. | Living Standard | Defined as NativeError.prototype. |
浏览器兼容性
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

