aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/functions/arguments/callee
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/javascript/reference/functions/arguments/callee
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/javascript/reference/functions/arguments/callee')
-rw-r--r--files/ru/web/javascript/reference/functions/arguments/callee/index.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/files/ru/web/javascript/reference/functions/arguments/callee/index.html b/files/ru/web/javascript/reference/functions/arguments/callee/index.html
new file mode 100644
index 0000000000..eaf41af79d
--- /dev/null
+++ b/files/ru/web/javascript/reference/functions/arguments/callee/index.html
@@ -0,0 +1,141 @@
+---
+title: arguments.callee
+slug: Web/JavaScript/Reference/Functions/arguments/callee
+translation_of: Web/JavaScript/Reference/Functions/arguments/callee
+---
+<div>{{jsSidebar("Functions")}}</div>
+
+<p>Свойство <code><strong>callee</strong> псевдомассива <strong>arguments</strong></code> хранит ссылку на функцию-родитель.</p>
+
+<h2 id="Описание">Описание</h2>
+
+<div class="warning"><strong>Внимание:</strong> В ES5 <a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode" title="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode">strict mode</a> использование <code>arguments.callee</code> запрещено.</div>
+
+<h3 id="Зачем_вообще_использовать_arguments.callee">Зачем вообще использовать <code>arguments.callee</code>?</h3>
+
+<p>В ранних версиях javaScript отсутствовала такая фишка, как <a href="https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Operators/function#%D0%98%D0%BC%D0%B5%D0%BD%D0%BE%D0%B2%D0%B0%D0%BD%D0%BD%D0%BE%D0%B5_%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%BE%D0%BD%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5_%D0%B2%D1%8B%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5">Named Function Expression </a>и единственным спасением было свойство <strong>callee</strong>. К примеру:</p>
+
+<pre class="brush: js">var f = function test() {
+ alert(typeof test); //undefined
+ alert(typeof arguments.callee); //function
+}
+</pre>
+
+<p>В нынешние времена, когда мы уже можем работать с <em>NFE</em>, надобность в использовании свойства <strong>callee </strong>сама собой отпадает<strong>.</strong></p>
+
+<pre class="brush: js">var f = function test(){
+ alert(typeof test); //function
+}</pre>
+
+<p> </p>
+
+<p>Действительно незаменимым оно остается всего в одной ситуации. Когда мы создаем анонимную функцию напрямую через конструктор <em>Function.</em></p>
+
+<pre class="line-numbers language-javascript"><code class="language-javascript"><span class="keyword token">var b = new Function("", "alert(typeof arguments.callee)");</span></code></pre>
+
+<p> </p>
+
+<h2 id="Пример_использования">Пример использования</h2>
+
+<p> </p>
+
+<h3 id="Использование_arguments.callee_для_создания_рекурсии">Использование <code>arguments.callee</code> для создания рекурсии</h3>
+
+<pre class="line-numbers language-javascript"><code class="language-javascript"><span class="keyword token">var factorial = function</span><span class="punctuation token">(</span>n<span class="punctuation token">)</span> <span class="punctuation token">{</span>
+ <span class="keyword token">return</span> n<span class="operator token"> == </span><span class="number token">1</span> <span class="operator token">?</span> <span class="number token">1</span> <span class="punctuation token">:</span> n<span class="operator token"> * </span>arguments<span class="punctuation token">.</span><span class="function token">callee</span><span class="punctuation token">(</span>n<span class="number token">-1</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+<span class="punctuation token">};
+
+</span><span class="keyword token">factorial</span></code>(7);
+</pre>
+
+<p> </p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.2</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-10.6', 'Arguments Object')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</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>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("Function")}}</li>
+</ul>