Resum
La propietat Error.prototype
representa el prototipus per al constructor Error
.
Property attributes of Error.prototype |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Descripció
Totes les instàncies de Error
i les instàncies de non-generic errors heretèn de Error.prototype
. Com totes les funcions constructores, es pot utilitzar el prototipus del constructor per a afegir propietats o mètodes a totes les instànces creades amb aquest constructor.
Propietats
Propietats standard
Error.prototype.constructor
- Especifica la funció que ha creat la instància del prototipus.
Error.prototype.message
- Missatge d'error.
Error.prototype.name
- Nom de l'error.
Extensions específiques del venedor
Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Microsoft
Error.prototype.description
- Descripció de l'error. Similar a
message
. Error.prototype.number
- Nombre de l'error.
Mozilla
Error.prototype.fileName
- Ruta al fitxer que ha llençat l'error.
Error.prototype.lineNumber
- Línia del fitxer que ha llençat l'error.
Error.prototype.columnNumber
- Nombre de columna de la línia que ha llençat l'error.
Error.prototype.stack
- Conté la traça de l'error.
Mètodes
Error.prototype.toSource()
- Retorna un string que conté el codi font de l'objecte
Error
especificat; es pot emprar aquest valor per a crear un objecte nou. Sobreescriu el mètodeObject.prototype.toSource()
. Error.prototype.toString()
- Retorna un string que representa l'objecte especificat. Sobreescriu el mètode
Object.prototype.toString()
.
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 1a Edició. | Standard | Definició inicial. Implementat a JavaScript 1.1. |
ECMAScript 5.1 (ECMA-262) The definition of 'Error' in that specification. |
Standard | |
ECMAScript 6 (ECMA-262) The definition of 'Error' in that specification. |
Release Candidate |
Compatibilitat amb navegadors
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |