What are the data types in TypeScript?
This one is a regular TypeScript interview question that almost every candidate faces. Here are the basic data types present in TypeScript described below.
- Number Types: In TypeScript, number values are floating values which have a type of number. Users can assign any numeric value, including hexadecimal, binary, decimals, and octal literals also.
- String Types: When a user desires to implement textual data, string types will be needed. It gets denoted by the keyword string.
- Boolean Types: It is used for declaring variables and accompanied by the keyword boolean.
- Enum Type: It can be used for numeric values with friendly names. It is declared with the keyword of “enum.”
- Void Types: Used for the function that doesn’t return any value.
- Null Types: Used to declare a variable type null. It can be assigned to boolean and number value.
- Undefined Types: It is used to store the value undefined.
- Any Types: It can be implemented to ensure data value to declare said values.
- Never Types: It represents the data type of values that never occur.
- Array Type: Used to declare data arrays.
- Tuple Types: This data type allows users to create an array where the fixed number type elements are known but not the same.
Suggest An Answer
No suggestions Available!