⊗tsSpIfIT 26 of 37 menu

Indexable type for objects in TypeScript

Now let's make an indexable type for the object. To do this, we'll create the IObject interface. We'll specify that the object's key will be a string and its value will be a number:

interface IObject { [index: string]: number; }

Let's give our variable a value in the form of an object with string keys and numeric values:

let obj: IObject = {'a': 1, 'b': 2, 'c': 3};

Create an interface that describes an object with keys as numbers and values ​​as strings.

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