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/add

/script>

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.add()

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 juillet 2015.

La méthode add() permet d'ajouter un nouvel élément ayant une valeur donnée à un ensemble Set. Cette valeur sera ajoutée à la fin de l'objet Set.

Exemple interactif

const set1 = new Set();

set1.add(42);
set1.add(42);
set1.add(13);

for (const item of set1) {
  console.log(item);
  // Expected output: 42
  // Expected output: 13
}

Syntaxe

js
monSet.add(valeur);

Paramètres

valeur

Ce paramètre est obligatoire. La valeur de l'élément qu'on souhaite ajouter à l'objet Set.

Valeur de retour

L'objet Set (ce qui permet de chaîner une suite d'instructions utilisant cette méthode).

Exemples

js
var monSet = new Set();

monSet.add(1);
monSet.add(5).add("du texte"); // ajouts en chaîne

console.log(monSet);
// Set [1, 5, "du texte"]

Spécifications

Spécification
ECMAScript® 2027 Language Specification
# sec-set.prototype.add

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