diff options
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/array/values')
-rw-r--r-- | files/pt-br/web/javascript/reference/global_objects/array/values/index.html | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/array/values/index.html b/files/pt-br/web/javascript/reference/global_objects/array/values/index.html new file mode 100644 index 0000000000..d3e918e1b9 --- /dev/null +++ b/files/pt-br/web/javascript/reference/global_objects/array/values/index.html @@ -0,0 +1,121 @@ +--- +title: Array.prototype.values() +slug: Web/JavaScript/Reference/Global_Objects/Array/values +translation_of: Web/JavaScript/Reference/Global_Objects/Array/values +--- +<div>{{JSRef}}</div> + +<p>O método <strong><code>values()</code></strong> retorna um novo objeto de <strong><code>Array Iterator</code></strong> que contém os valores para cada índice no array.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox"><code><var>arr</var>.values()</code></pre> + +<h2 id="Exemplos">Exemplos</h2> + +<h3 id="Iteração_usando_for...of_loop">Iteração usando <code>for...of</code> loop</h3> + +<pre class="brush: js">var arr = ['w', 'y', 'k', 'o', 'p']; +var eArr = arr.values(); +// seu navegador deve suportar for..of loop +// e deixar variáveis let-scoped no for loops +for (let letter of eArr) { + console.log(letter); +} +</pre> + +<h3 id="Iteração_alternativa">Iteração alternativa</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="Especificações">Especificações</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Status</th> + <th scope="col">Comentário</th> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-array.prototype.values', 'Array.prototype.values')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Definição inicial.</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade_de_navegadores">Compatibilidade de navegadores</h2> + +<div>{{CompatibilityTable}}</div> + +<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>Suporte básico</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</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>Suporte básico</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Notas_específicas_do_Firefox">Notas específicas do Firefox</h2> + +<ul> + <li>Devido a um <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=875433">problema de compatibilidade</a>, <code>Array.prototype.values()</code> foi removido do SpiderMonkey por enquanto.</li> +</ul> + +<h2 id="Ver_também">Ver também</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> |