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

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.

主站蜘蛛池模板: 威海市| 都兰县| 永胜县| 大厂| 兖州市| 凤山县| 汝州市| 兴城市| 饶阳县| 华坪县| 交城县| 肇庆市| 敖汉旗| 资中县| 阿鲁科尔沁旗| 宽甸| 萝北县| 博兴县| 万宁市| 曲阜市| 武穴市| 普兰县| 托里县| 手游| 长乐市| 钦州市| 伊宁县| 酉阳| 汪清县| 沅江市| 比如县| 沙坪坝区| 隆子县| 石阡县| 苍南县| 涿州市| 南平市| 安阳市| 汪清县| 潞西市| 高州市|