using es6 set in typescript typescript set set in typescript

The solution for “using es6 set in typescript typescript set set in typescript” can be found here. The following code will assist you in solving the problem.

const [elements, setElements] = useState>(new Set())const [elements, setElements] = useState>(new Set())//Create a Set
let diceEntries = new Set();

//Add values
diceEntries.add(4).add(5).add(6); //Chaining of add() method is allowed

//Check value is present or not
diceEntries.has(1); //true
diceEntries.has(10); //false

//Size of Set
diceEntries.size; //6

//Delete a value from set
diceEntries.delete(6); // true

//Clear whole Set
diceEntries.clear(); //Clear all entries

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in