In this article we will learn about some of the frequently asked TypeScript programming questions in technical like “set in typescript” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on typescript was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in Typescript. Below are some solution about “set in typescript” Code Answer.
set in typescript
xxxxxxxxxx
1
//Create a Set
2
let diceEntries = new Set();
3
4
//Add values
5
diceEntries.add(1);
6
diceEntries.add(2);
7
diceEntries.add(3);
8
diceEntries.add(4).add(5).add(6); //Chaining of add() method is allowed
9
10
//Check value is present or not
11
diceEntries.has(1); //true
12
diceEntries.has(10); //false
13
14
//Size of Set
15
diceEntries.size; //6
16
17
//Delete a value from set
18
diceEntries.delete(6); // true
19
20
//Clear whole Set
21
diceEntries.clear(); //Clear all entries