⊗jstsPmBsDT 3 of 55 menu

Data Types in TypeScript

In TypeScript, when declaring a variable, we must specify its type. To do this, we must write a colon after the variable name, and then specify the desired type.

For example, let's make a string variable:

let test: string = 'abc';

And now the numerical one:

let test: number = 123;

And now the logical one:

let test: boolean = true;

It is not necessary to assign a value to a variable immediately when declaring it. You can first declare the variable, and then assign a value to it later in the code. Example:

let test: string; test = 'abc';

Make three variables: one string, one number, and one boolean.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline