Answers for "set in typescript"

0

set in typescript

//Create a Set
let diceEntries = new Set();
 
//Add values
diceEntries.add(1);
diceEntries.add(2);
diceEntries.add(3);
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
Posted by: Guest on July-08-2021

Code answers related to "set in typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language