From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../reference/global_objects/array/values/index.md | 90 +++++++++------------- 1 file changed, 38 insertions(+), 52 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/array/values') diff --git a/files/fr/web/javascript/reference/global_objects/array/values/index.md b/files/fr/web/javascript/reference/global_objects/array/values/index.md index 881e840bd4..d7f591029d 100644 --- a/files/fr/web/javascript/reference/global_objects/array/values/index.md +++ b/files/fr/web/javascript/reference/global_objects/array/values/index.md @@ -12,13 +12,14 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/Array/values original_slug: Web/JavaScript/Reference/Objets_globaux/Array/values --- -
{{JSRef}}
+{{JSRef}} -

La méthode values() renvoie un nouvel objet Array Iterator qui contient les valeurs pour chaque indice du tableau. Cette méthode est l'implémentation par défaut de Array.prototype[Symbol.Iterator].

+La méthode **`values()`** renvoie un nouvel objet **`Array Iterator`** qui contient les valeurs pour chaque indice du tableau. Cette méthode est l'implémentation par défaut de `Array.prototype[Symbol.Iterator]`. -

{{EmbedInteractiveExample("pages/js/array-values.html")}}

+{{EmbedInteractiveExample("pages/js/array-values.html")}} -
var a = ['t', 'i', 't', 'o', 'u'];
+```js
+var a = ['t', 'i', 't', 'o', 'u'];
 var iterateur = a.values();
 
 console.log(iterateur.next().value); // t
@@ -26,72 +27,57 @@ console.log(iterateur.next().value); // i
 console.log(iterateur.next().value); // t
 console.log(iterateur.next().value); // o
 console.log(iterateur.next().value); // u
-
+``` -

Syntaxe

+## Syntaxe -
array.values()
+ array.values() -

Valeur de retour

+### Valeur de retour -

Un nouvel objet itérateur sur {{jsxref("Array")}}.

+Un nouvel objet itérateur sur {{jsxref("Array")}}. -

Exemples

+## Exemples -

Itérer avec une boucle for...of

+### Itérer avec une boucle `for...of` -
var arr = ['w', 'y', 'k', 'o', 'p'];
+```js
+var arr = ['w', 'y', 'k', 'o', 'p'];
 var eArr = arr.values();
 // votre navigateur doit supporter les boucles for..of
 // et les variables définies avec let
 for (let lettre of eArr) {
   console.log(lettre);
 }
-
+``` -

Itérer avec next()

+### Itérer avec `next()` -
var arr = ['w', 'y', 'k', 'o', 'p'];
+```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
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES2015', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ES2015')}}Définition initiale.
{{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.Array.values")}}

- -

Voir aussi

- - +``` + +## Spécifications + +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------- | -------------------- | +| {{SpecName('ES2015', '#sec-array.prototype.values', 'Array.prototype.values')}} | {{Spec2('ES2015')}} | Définition initiale. | +| {{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}} | {{Spec2('ESDraft')}} |   | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.Array.values")}} + +## Voir aussi + +- {{jsxref("Array.prototype.keys()")}} +- {{jsxref("Array.prototype.entries()")}} +- {{jsxref("Array.prototype.forEach()")}} +- {{jsxref("Array.prototype.every()")}} +- {{jsxref("Array.prototype.some()")}} -- cgit v1.2.3-54-g00ecf