TS02: BuiltIn DataTypes and Arrays

TS02: BuiltIn DataTypes and Arrays

·

1 min read

Table of contents

Today, We are going through builtin types : number, string, boolean and also any types, and arrays.

Builtin Types

There are 5 built-in types in Typescript.

  • number: only allows a number

  • string: only allows characters and string

  • boolean: only allow true and false

  • void: doesn't allow anything.

  • any: allows everything

Let's see their syntax,

Note: If we don't specify the type, It will take any as default type.

Arrays

In Javascript, we can have an array with different types of elements. But in TypeScriopt we can create an array that has only one type of element.

With strongly typed arrays, we can get different methods regarding that datatype.

I hope this blog has brought knowledge to you about TypeScript. For more such articles follow me and subscribe to my newsletter. If you haven't read the first article. Please click this link and read to get started.

Also, follow me on Twitter and Linkedin.

Thank You. ❤️