What are the built in Data Types in Typescript?

In TypeScript, there are five data types: String, Boolean, Number, Null, and Undefined.

  • String: The string data type is used to represent text in TypeScript. Strings work with textual data. Strings are always enclosed in single or double quotes.
    Syntax:

       let identifier: string = " ";
    
  • Number: Numbers in TypeScript store floating-point values. They can be represented as both integer and fraction.

Syntax:

         let identifier: number = value;
  • Boolean: The boolean data type can only have one of the two values - “true” or “false”. It specifies whether a condition is true or false.
    Syntax:

let identifier: Boolean = Boolean value;

  • Null: Null is a variable whose value is undefined. It accepts only one value, Null.
  let num: number = null;

         let bool: boolean= null;

         let str: string= null;
  • Undefined: The undefined primitive type denotes all the uninitialised variables in TypeScript.
     let num: number = undefined;

         let bool: boolean= undefined;

         let str: string= undefined;