Google News
logo
TypeScript - Interview Questions
List out the built-in data types in TypeScript.
The built-in data types are also known as primitive data types in Typescript. These are given below.
 
Number type : It is used to represent number type values. All the numbers in TypeScript are stored as floating point values.
Syntax : let identifier: number = value;
 
String type : It represents a sequence of characters stored as Unicode UTF-16 code. We include string literals in our scripts by enclosing them in single or double quotation marks.
Syntax : let identifier: string = " ";
 
Boolean type : It is used to represent a logical value. When we use the Boolean type, we get output only in true or false. A Boolean value is a truth value that specifies whether the condition is true or not.
Syntax : let identifier: bool = Boolean value;
 
Null type : Null represents a variable whose value is undefined. It is not possible to directly reference the null type value itself. Null type is not useful because we can only assign a null value to it.
Syntax : let num: number = null;
 
Undefined type : It is the type of undefined literal. The Undefined type denotes all uninitialized variables. It is not useful because we can only assign an undefined value to it. This type of built-in type is the sub-type of all the types.
Syntax : let num: number = undefined;
 
Void type : A void is the return type of the functions that do not return any type of value. It is used where no datatype is available.
Syntax : let unusable: void = undefined;
Advertisement