⊗jstsPmFnRP 51 of 55 menu

Rest function parameters in TypeScript

In TypeScript, you can also work with rest function parameters. To do this, the variable into which the parameters are stored should be declared as an array:

function func(...rest: number[]): void { console.log(rest); }

Let's check how our function works:

func(1, 2, 3); // will bring out [1, 2, 3]

Make a function that takes any number of numbers as parameters and returns their sum.

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