CodesJava

Easy learning with example program codes

TypeScript Data Types system


When a variable is declared some part of memory is reserved. But how much memory will be reserved. It depends upon the data type of the variable.  i.e. how much memory will be reserved and which type of data can be stored in reserved memory is depends upon data type of the variable. The Type System of a language represents these data types.

Data types in TypeScript:

  1. Any Type: represents the super type of all data types in TypeScript. TypeScript provides the compile time data type-checking for the variables. In some situation we may not know what type of value for variable will come. These values may come from dynamic content e.g. from the user. In such cases, we want to opt-out of type-checking and let the values pass through compile-time checks. The any type is used for these variables.

  2. Built-in types:
  3. Data type Keyword Description
    Number number It represents a double precision 64-bit floating point values which can be used to represent both integers and fractions.
    String string It represents a sequence of characters.
    Boolean boolean It represents logical values true and false.
    Void void It is used on function return types to represent non-returning functions.
    Null null It is used to represent an intentional absence of an object value.
    Undefined undefined It represents uninitialized variables.
  4. User-defined types: include Enumerations (enums), classes, interfaces, arrays, and tuple.


Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki