Basic Concepts and Syntax of TypeScript

  • A TypeScript code comprise of variables, functions, statements, comments etc.
  • The identifiers, such as variables and function name, can include characters or digits or both. But they cannot begin with digits.
  • Identifiers cannot contain special symbols except underscore(_) or dollar sign($). We cannot use keywords as identifiers and they must be unique within a scope. They are case-sensitive and cannot contain spaces. Some examples of Identifiers are: firstName, last_Name, number1 etc.
  • TypeScript is case-sensitive that means it can differentiate between uppercase and lowercase. For example, name and Name are two different identifiers in TypeScript.
  • Each line of code is called a statement. Semicolon (;) are optional at the end of the statement.
  • If you include multiple statements in a single line, then those statements must be separated using semicolon.
  • There are two types f comments in TypeScript:
    • Single Line Comments(//): Any text between // and the end of the line is considered as comment and will not be executed.
    • Multiple Line Comments(/* */): Any text between /* and */ are considered as comment even if it spans multiple lines and will not be executed.

 

 

Design a site like this with WordPress.com
Get started