diff options
Diffstat (limited to 'files/ru/web/javascript/reference/global_objects/array/values/index.html')
-rw-r--r-- | files/ru/web/javascript/reference/global_objects/array/values/index.html | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/files/ru/web/javascript/reference/global_objects/array/values/index.html b/files/ru/web/javascript/reference/global_objects/array/values/index.html new file mode 100644 index 0000000000..bdd8c8c2f6 --- /dev/null +++ b/files/ru/web/javascript/reference/global_objects/array/values/index.html @@ -0,0 +1,136 @@ +--- +title: Array.prototype.values() +slug: Web/JavaScript/Reference/Global_Objects/Array/values +tags: + - Array + - ECMAScript6 + - Experimental + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Array/values +--- +<div>{{JSRef("Global_Objects", "Array")}}</div> + +<h2 id="Summary" name="Summary">Сводка</h2> + +<p>Метод <strong><code>values()</code></strong> возвращает новый объект итератора массива <strong><code>Array Iterator</code></strong>, содержащий значения для каждого индекса в массиве.</p> + +<h2 id="Syntax" name="Syntax">Синтаксис</h2> + +<pre class="syntaxbox"><code><var>arr</var>.values()</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']; +var eArr = arr.values(); +// ваш браузер должен поддерживать цикл for...of и переменные, +// объявленные через let в циклах for +for (let letter of eArr) { + 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.values(); +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.values', 'Array.prototype.values')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Изначальное определение.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}}</td> + <td>{{Spec2('ESDraft')}}</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>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>9</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>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h3 id="Firefox-specific_notes" name="Firefox-specific_notes">Примечание по Firefox</h3> + +<ul> + <li>Из-за <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=875433">проблемы с совместимостью</a> метод <code>Array.prototype.values()</code> в данный момент убран из SpiderMonkey.</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> +</ul> |