By 06/07/2015 13 Comments

Basic Data Types In TypeScript

Basic Data Types:

  • TypeScript is a strong type programming language.
  • It defines three basic data types: number, string and boolean and that feature is described as “syntactic sugar” by TypeScript designer.
  • TypeScript uses a colon (:) sign to specify the data type for a variable.
  • Data types describe the different kind of information.
  • TypeScript creates a powerful rule of strong typing, if we break that rule the TypeScript compiler generates compile-time errors.

Syntax:

var var-name:datatype = “value”;

var:

  • This keyword indicates a local variable.

var-name:

  • Any valid meaningful name. This can be a variable name.

:

  • Colon (:) sign which makes a variable to a specific type such as var ideName : string = “visual studio”, where ideName is became of type string and it cannot hold any other data type.

datatype:

  • Such as string, boolean or number etc.

=

  • Assignment operator which assigns values to a variable from right-side to left.

value:

  • It can be any value depends on its variable type such as string literals, boolean true, false, numbers etc.

Example:

// following is a string type local variable initialization.
var typeScript: string = "TypeScript programming language.";

// following is a number type local variable initialization.
var pi: number = 3.14;

// following is a boolean type local variable initialization.
var isChecked: boolean = true;

// print the above variables.
document.write("Technology name is: " + typeScript + " <br/>");
document.write("The value of pi is: " + pi + " <br/>");
document.write("TypeScript is a strong typed language: " + isChecked);







Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .