官术网_书友最值得收藏!

Rest parameter

Using the rest parameter, you can pass an array of values to the function. This can be used in scenarios where you are not sure about how many values will be supplied to the function:

function clientName(firstClient: string, ...restOfClient: string[]) { 
   console.log(firstClient + " " + restOfClient.join(" ")); 
} 
clientName ("Scott", "Steve", "Bill", "Sergey", "Larry"); 

Here, note that the restOfClient rest parameter is prefixed with an ellipsis (...), and it can hold an array of strings. In the caller of the function, only the value of the first parameter that is supplied will be assigned to the firstClient parameter, and the remaining values will be assigned to restOfClient as array values.

主站蜘蛛池模板: 湟中县| 大厂| 兴海县| 安达市| 麻城市| 耒阳市| 濮阳县| 钟山县| 崇明县| 屏东市| 湟源县| 津市市| 高密市| 怀来县| 兴宁市| 池州市| 高邑县| 霍山县| 安吉县| 营山县| 瑞安市| 龙陵县| 沧州市| 兴化市| 哈密市| 灵璧县| 文昌市| 高陵县| 扬州市| 伊金霍洛旗| 若尔盖县| 射阳县| 泉州市| 凤山县| 云安县| 旺苍县| 左贡县| 富蕴县| 正镶白旗| 金门县| 江西省|