On the third day of 100daysofcode challenge, learned the basics of types in TypeScript.
Types in TypeScript are just a simple way to describe the properties and function of a value.
const name = "Abhay Nikam"
name is of type string which has different properties and function.
// Example of some properties for type string value name.charAt(); name.indexOf();
- Primitive Types: number, boolean, void, undefined, string, symbol, null.
- Object Types: functions, arrays, classes, objects.
NOTE: I haven't yet studied all types in details. Will be learning
that in the next few days.
There is a simple answer to this question. We care about types because types give the required information to the TypeScript compiler to analyze the value and throw an error if something is not as per type defined.
Types also help the other developers in the team to understand what properties and function value might have.
Happy Friday. Happy Coding.