aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/error/tosource
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 14:45:12 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 14:45:12 +0100
commitcb9e359a51c3249d8f5157db69d43fd413ddeda6 (patch)
treeae3040d626c3b5717da5bda2af9f0a9ff9bd389f /files/ca/web/javascript/reference/global_objects/error/tosource
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-cb9e359a51c3249d8f5157db69d43fd413ddeda6.tar.gz
translated-content-cb9e359a51c3249d8f5157db69d43fd413ddeda6.tar.bz2
translated-content-cb9e359a51c3249d8f5157db69d43fd413ddeda6.zip
unslug ca: move
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/error/tosource')
-rw-r--r--files/ca/web/javascript/reference/global_objects/error/tosource/index.html91
1 files changed, 91 insertions, 0 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/error/tosource/index.html b/files/ca/web/javascript/reference/global_objects/error/tosource/index.html
new file mode 100644
index 0000000000..c766aa312b
--- /dev/null
+++ b/files/ca/web/javascript/reference/global_objects/error/tosource/index.html
@@ -0,0 +1,91 @@
+---
+title: Error.prototype.toSource()
+slug: Web/JavaScript/Referencia/Objectes_globals/Error/toSource
+translation_of: Web/JavaScript/Reference/Global_Objects/Error/toSource
+---
+<div>{{JSRef}} {{non-standard_header}}</div>
+
+<p>El mètode <code><strong>toSource()</strong></code> reotrna codi capaç de generar el mateix error en case de ser evaluat.</p>
+
+<h2 id="Sintaxi">Sintaxi</h2>
+
+<pre class="syntaxbox"><code><var>e</var>.toSource()</code></pre>
+
+<h2 id="Descripció">Descripció</h2>
+
+<p>La crida al mètode <code>toSource</code> d'una instància d'{{jsxref("Error")}}(incloent <em><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types">NativeErrors</a></em>) 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 {{jsxref("Error")}}. Per exemple:</p>
+
+<pre class="brush: js">(new<em>name</em>(<em>message</em> ,<em>fileName</em>,<em>lineNumber</em>))
+</pre>
+
+<p>on aquests atributs corresponen a les propietats de la instància de l'error, respectivament.</p>
+
+<div class="note">
+<p><strong>Advertència:</strong> Cal tenir en compte que les propietats utilitzades pel mètode <code>toSource</code> 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.</p>
+</div>
+
+<h2 id="Especificacions">Especificacions</h2>
+
+<p>No forma part de cap standard. Implementat a JavaScript 1.3.</p>
+
+<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Vegeu_també">Vegeu també</h2>
+
+<ul>
+ <li>{{jsxref("Error.prototype.fileName")}}</li>
+ <li>{{jsxref("Error.prototype.lineNumber")}}</li>
+ <li>{{jsxref("Error.prototype.message")}}</li>
+ <li>{{jsxref("Error.prototype.name")}}</li>
+ <li>{{jsxref("Object.prototype.toSource()")}}</li>
+</ul>