cover-img

#Day5 - "Non-Primitive" Data Types in Typescript

1 September, 2022

0

0

0

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.

0

0

0

Fathan Margono

Jakarta, Indonesia

Self-taught software engineer with 6 years of experience, passionate about JavaScript and user-friendly interfaces, constantly seeking new challenges.

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.