
#Day5 - "Non-Primitive" Data Types in Typescript
1 September, 2022
0
0
0
Contributors
Maybe for primitive data types are very clear to learn, we just have to add colon + the primitive data types.
But, it's not a little bit different for non-primitive data types (Such as Array & Object).
Object
Here is how we define Object types, we add colon with object like usual (like key value pairs), but the value are not the real value, instead the type itself
Array
It's quite simple too, just add the type along with square bracket
The example above code is we defined a variable with the data type of array of string. So it means we can't add or replace the item of elements with different types, it will throw an error.