Set.prototype.clear()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

La méthode clear() permet de retirer tous les éléments d'un ensemble Set.

Exemple interactif

const set1 = new Set();
set1.add(1);
set1.add("foo");

console.log(set1.size);
// Expected output: 2

set1.clear();

console.log(set1.size);
// Expected output: 0

Syntaxe

js
monSet.clear();

Valeur de retour