aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/function/caller/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/function/caller/index.html')
-rw-r--r--files/ca/web/javascript/reference/global_objects/function/caller/index.html124
1 files changed, 124 insertions, 0 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/function/caller/index.html b/files/ca/web/javascript/reference/global_objects/function/caller/index.html
new file mode 100644
index 0000000000..613e163d6a
--- /dev/null
+++ b/files/ca/web/javascript/reference/global_objects/function/caller/index.html
@@ -0,0 +1,124 @@
+---
+title: Function.caller
+slug: Web/JavaScript/Reference/Global_Objects/Function/caller
+translation_of: Web/JavaScript/Reference/Global_Objects/Function/caller
+---
+<div>{{JSRef}} {{non-standard_header}}</div>
+
+<p>La propietat <code><strong><em>function</em>.caller</strong></code> retorna la funció que ha invocat la funció especificada.</p>
+
+<h2 id="Descripció">Descripció</h2>
+
+<p>SI la funció <code>f</code> ha estat invocada pel codi de nivell superior, el valor de <code>f.caller</code> és {{jsxref("null")}}, sinó és la funció que ha cridat <code>f</code>.</p>
+
+<p>Aquesta propietat reemplaça la propietat obsoleta {{jsxref("Functions/arguments/caller", "arguments.caller")}} de l'objecte {{jsxref("Functions/arguments", "arguments")}}.</p>
+
+<p>La propietat especial <code>__caller__</code>, la qual retorna l'objecte activatwhich returned the activation object of the caller thus allowing to reconstruct the stack, was removed for security reasons.</p>
+
+<h3 id="Notes">Notes</h3>
+
+<p>Vegeu que en cas de recursió, no podeu reconstruir la pila de crida fent servir aquesta propietat. C that in case of recursion, you can't reconstruct the call stack using this property. Tingueu en compte:</p>
+
+<pre class="brush: js">function f(n) { g(n - 1); }
+function g(n) { if (n &gt; 0) { f(n); } else { stop(); } }
+f(2);
+</pre>
+
+<p>At the moment <code>stop()</code> is called the call stack will be:</p>
+
+<pre class="brush: js">f(2) -&gt; g(1) -&gt; f(1) -&gt; g(0) -&gt; stop()
+</pre>
+
+<p>El següent és cert:</p>
+
+<pre class="brush: js">stop.caller === g &amp;&amp; f.caller === g &amp;&amp; g.caller === f
+</pre>
+
+<p>so if you tried to get the stack trace in the <code>stop()</code> function like this:</p>
+
+<pre class="brush: js">var f = stop;
+var stack = 'Stack trace:';
+while (f) {
+ stack += '\n' + f.name;
+ f = f.caller;
+}
+</pre>
+
+<p>El bucle mai s'aturaria.</p>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Checking_the_value_of_a_function's_caller_property">Checking the value of a function's <code>caller</code> property</h3>
+
+<p>El codi següent comprova que el valor following code checks the value a function's <code>caller</code> property.</p>
+
+<pre class="brush: js">function myFunc() {
+ if (myFunc.caller == null) {
+ return 'The function was called from the top!';
+ } else {
+ return 'This function\'s caller was ' + myFunc.caller;
+ }
+}
+</pre>
+
+<h2 id="Especificacions">Especificacions</h2>
+
+<p>No forma part de cap especificació. Implementat en JavaScript 1.5.</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>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoDesktop("1.0")}}</td>
+ <td>8.0</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Chrome per 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>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatGeckoMobile("1.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Vegeu_també">Vegeu també</h2>
+
+<ul>
+ <li>Error d'Implementació de SpiderMonkey {{bug(65683)}}</li>
+</ul>