But whats the difference between dynamic and static typing?
Every feature provided in TypeScript is non-invading, meaning that it has syntax that doesn't overlap with any part of the JS code. This makes porting your JS app back and forth relatively easily.
You can specify your variable's type using the colon (:) followed by the actual name of the type:
const stringVar: string = "str";
There are 6 basic, primitive types to remember:
number // represents any kind of numeric value
string // represents any kind of string value;
boolean // represents any boolean value, i.e. true or false;
symbol // represents symbol values;
null // represents null value only;
undefined //represents undefined value only;
What does TypeScript offer ?
- Class Based Objects – Another huge advantage is the use of Classes which provides the ability to use true object oriented programming in our applications and prevents use of prototype based objects. It also provides encapsulation, inheritance and modifiers.
- Modularity – It helps make the code more modular.
- ES6 Features – Support for ES6 features is also one of the main reasons for its popularity.
- Syntax – TypeScript provides syntax which is closer to java and other high level languages (Syntactical Sugaring).
Top comments (0)