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

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.

主站蜘蛛池模板: 平阴县| 仁布县| 阿城市| 尚义县| 仁寿县| SHOW| 融水| 郎溪县| 沙雅县| 南汇区| 嘉禾县| 西畴县| 隆化县| 怀集县| 边坝县| 凤山市| 鲜城| 清水河县| 兴宁市| 阳新县| 嫩江县| 于都县| 托克逊县| 汽车| 镇安县| 都兰县| 佛坪县| 上杭县| 奎屯市| 清丰县| 白沙| 汉川市| 沿河| 晋宁县| 海宁市| 和顺县| 贡嘎县| 临江市| 若羌县| 莲花县| 雷波县|