July 2019
Intermediate to advanced
416 pages
10h 6m
English
The final thing we need to look at with regard to REST is the idea of functions having REST parameters. These aren't the same as REST properties but the syntax is so similar that we should find it easy to pick up. The problem that REST parameters solves is to cope with a variable number of parameters being passed into a function. The way to identify a REST parameter in a function is that it is preceded by the ellipsis and that it is typed as an array.
In this example, we are going to log out a header followed by a variable number of instruments:
function PrintInstruments(log : string, ...instruments : string[]) : void { console.log(log); instruments.forEach(instrument => { console.log(instrument); ...Read now
Unlock full access