diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
commit | 074785cea106179cb3305637055ab0a009ca74f2 (patch) | |
tree | e6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/javascript/reference/global_objects/array/@@iterator | |
parent | da78a9e329e272dedb2400b79a3bdeebff387d47 (diff) | |
download | translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2 translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip |
initial commit
Diffstat (limited to 'files/ru/web/javascript/reference/global_objects/array/@@iterator')
-rw-r--r-- | files/ru/web/javascript/reference/global_objects/array/@@iterator/index.html | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/files/ru/web/javascript/reference/global_objects/array/@@iterator/index.html b/files/ru/web/javascript/reference/global_objects/array/@@iterator/index.html new file mode 100644 index 0000000000..9de1e97f40 --- /dev/null +++ b/files/ru/web/javascript/reference/global_objects/array/@@iterator/index.html @@ -0,0 +1,138 @@ +--- +title: 'Array.prototype[@@iterator]()' +slug: Web/JavaScript/Reference/Global_Objects/Array/@@iterator +tags: + - Array + - ECMAScript6 + - Experimental + - Expérimental(2) + - Iterator + - JavaScript + - Method + - Prototype + - Reference + - Référence(2) +translation_of: Web/JavaScript/Reference/Global_Objects/Array/@@iterator +--- +<div>{{JSRef("Global_Objects", "Array")}}</div> + +<h2 id="Summary" name="Summary">Сводка</h2> + +<p>Начальное значение свойства <strong><code>@@iterator</code></strong> является тем же самым функциональным объектом, что и начальное значение, возвращаемое методом {{jsxref("Array.prototype.values()", "values()")}}.</p> + +<h2 id="Syntax" name="Syntax">Синтаксис</h2> + +<pre class="syntaxbox"><code><var>arr</var>[Symbol.iterator]()</code></pre> + +<h2 id="Examples" name="Examples">Примеры</h2> + +<h3 id="Example:_Iteration_using_for...of_loop" name="Example:_Iteration_using_for...of_loop">Пример: итерация посредством цикла <code>for...of</code></h3> + +<pre class="brush: js">var arr = ['w', 'y', 'k', 'o', 'p']; +// ваш браузер должен поддерживать цикл for..of +// и переменные с областью видимости let в циклах for +for (let letter of arr) { + console.log(letter); +} +</pre> + +<h3 id="Example:_Alternative_iteration" name="Example:_Alternative_iteration">Пример: альтернативный способ итерации</h3> + +<pre class="brush: js">var arr = ['w', 'y', 'k', 'o', 'p']; +var eArr = arr[Symbol.iterator](); +console.log(eArr.next().value); // w +console.log(eArr.next().value); // y +console.log(eArr.next().value); // k +console.log(eArr.next().value); // o +console.log(eArr.next().value); // p +</pre> + +<h2 id="Specifications" name="Specifications">Спецификации</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Спецификация</th> + <th scope="col">Статус</th> + <th scope="col">Комментарии</th> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-array.prototype-@@iterator', 'Array.prototype[@@iterator]()')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Изначальное определение.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Совместимость с браузерами</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Возможность</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Базовая поддержка</td> + <td>{{CompatChrome("38")}}</td> + <td>{{CompatGeckoDesktop("17")}} (.iterator)<br> + {{CompatGeckoDesktop("27")}} (["@@iterator"])<br> + {{CompatGeckoDesktop("36")}} ([Symbol.iterator])</td> + <td>{{CompatNo}}</td> + <td>{{CompatOpera("25")}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Возможность</th> + <th>Android</th> + <th>Chrome для Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Базовая поддержка</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatGeckoMobile("17")}} (.iterator)<br> + {{CompatGeckoMobile("27")}} (["@@iterator"])<br> + {{CompatGeckoMobile("36")}} ([Symbol.iterator])</td> + <td>{{CompatNo}}</td> + <td>{{CompatOpera("25")}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h3 id="Gecko-specific_notes" name="Gecko-specific_notes">Примечания по Gecko</h3> + +<ul> + <li>С Gecko 17 {{geckoRelease("17")}} по Gecko 26 {{geckoRelease("26")}} вместо {{jsxref("Global_Objects/Symbol", "символа", "", 1)}} <code>@@iterator</code> использовалось свойство <code>iterator</code> ({{bug(907077)}}), а с Gecko 27 по Gecko 35 — строка-заменитель <code>"@@iterator"</code> ({{bug("918828")}}).</li> +</ul> + +<h2 id="See_also" name="See_also">Смотрите также</h2> + +<ul> + <li>{{jsxref("Array.prototype.keys()")}}</li> + <li>{{jsxref("Array.prototype.entries()")}}</li> + <li>{{jsxref("Array.prototype.forEach()")}}</li> + <li>{{jsxref("Array.prototype.every()")}}</li> + <li>{{jsxref("Array.prototype.some()")}}</li> + <li>{{jsxref("Array.prototype.values()")}}</li> +</ul> |