pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Set/Symbol.iterator

ipt>

Cette page a été traduite à partir de l'anglais par la communauté. Vous pouvez contribuer en rejoignant la communauté francophone sur MDN Web Docs.

View in English Always switch to English

Set.prototype[@@iterator]()

Baseline Large disponibilité

Cette fonctionnalité est bien établie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis septembre 2015.

La valeur initiale de la propriété @@iterator est le même objet fonction que la valeur initiale de la propriété Set.prototype.values.

Exemple interactif

const set1 = new Set();

set1.add(42);
set1.add("forty two");

const iterator1 = set1[Symbol.iterator]();

console.log(iterator1.next().value);
// Expected output: 42

console.log(iterator1.next().value);
// Expected output: "forty two"

Syntaxe

js
monSet[Symbol.iterator];

Valeur de retour

La fonction associée au symbole @@iterator de l'objet. Par défaut, c'est la fonction values().

Exemples

Utiliser [@@iterator]()

js
const monSet = new Set();
monSet.add("0");
monSet.add(1);
monSet.add({});

const setIter = monSet[Symbol.iterator]();

console.log(setIter.next().value); // "0"
console.log(setIter.next().value); // 1
console.log(setIter.next().value); // {}

Utiliser [@@iterator]() avec une boucle for..of

js
const monSet = new Set();
monSet.add("0");
monSet.add(1);
monSet.add({});

for (const v of monSet) {
  console.log(v);
}

Spécifications

Spécification
ECMAScript® 2027 Language Specification
# sec-set.prototype-%symbol.iterator%

Compatibilité des navigateurs

Voir aussi

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy