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

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.

主站蜘蛛池模板: 丘北县| 银川市| 柳州市| 靖宇县| 抚宁县| 巧家县| 灌阳县| 宝山区| 安塞县| 射洪县| 肇源县| 黔西| 周至县| 若尔盖县| 贡嘎县| 宝丰县| 桐乡市| 富平县| 榆社县| 琼海市| 嵊州市| 九龙县| 卢龙县| 葫芦岛市| 赤水市| 会泽县| 方山县| 莱阳市| 咸丰县| 株洲市| 井研县| 韶山市| 沁阳市| 泗洪县| 辰溪县| 乌鲁木齐县| 晋江市| 阿鲁科尔沁旗| 平利县| 德庆县| 宜黄县|