#10 Literal Types (Advanced Types)

 We can have a constant with two values types. Like in example;

Let quantity:50 | 100=100

Here, the quantity is assigned to 50 or 100. So the value of quantity can only be 50 or 100 else it shows an error. It can also be used for strings.

Comments

Popular posts from this blog

#6 Objects (Fundamentals of TS)

#8 Union Type (Advanced Types)