⊗jstsPmTpFl 27 of 55 menu

Filling a Tuple in TypeScript

Using the rest operator, you can define a set of elements in a tuple consisting of an arbitrary number of values ​​that have the same type.

As an example, let's make a tuple where the first element must be a string, followed by an arbitrary number of numbers:

let tpl: [string, ...number[]];

Let's fill our tuple with data:

tpl = ['str', 1, 2, 3, 4, 5];

Fill in the following tuple with data:

let tpl: [string, string, ...number[]];

Fill in the following tuple with data:

let tpl: [number, boolean, ...string[]];
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