Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Error.prototype.toSource()

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.

El mètode toSource() reotrna codi capaç de generar el mateix error en case de ser evaluat.

Sintaxi

e.toSource()

Descripció

La crida al mètode toSource d'una instància d'Error(incloent NativeErrors) retorna un string que conté el codi font de l'error. Aquest string pot ser evaluat per a crear un objecte (aproximadament) igual. Per defecte la string contenint el codi font segueix l'estructura del construtor Error. Per exemple:

(newname(message ,fileName,lineNumber))

on aquests atributs corresponen a les propietats de la instància de l'error, respectivament.

Advertència: Cal tenir en compte que les propietats utilitzades pel mètode toSource a l'hora de crear l'string són mutables i per tant poden no representar de forma acurada la funció utilitzada per a crear la instància de l'error, el nom del fitxer o el nombre de la línia on l'error real ha tingut lloc.

Especificacions

No forma part de cap standard. Implementat a JavaScript 1.3.

Compatibilitat amb navegadors

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic ? (Yes) ? ? ?
Característica Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic ? ? (Yes) ? ? ?

Vegeu també

Document Tags and Contributors

 Contributors to this page: enTropy
 Last updated by: enTropy,