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

  • Expert Angular
  • Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
  • 113字
  • 2021-07-15 17:05:33

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.

主站蜘蛛池模板: 阳江市| 南木林县| 诏安县| 贵阳市| 名山县| 苍山县| 聊城市| 明光市| 滁州市| 北安市| 定安县| 吉木萨尔县| 原阳县| 万全县| 卓资县| 台东县| 桃源县| 台东县| 阳泉市| 镇远县| 神农架林区| 台中县| 托克托县| 漳浦县| 榆社县| 徐汇区| 天峻县| 城固县| 昌邑市| 彭山县| 西华县| 静宁县| 柘荣县| 定结县| 桃江县| 盈江县| 策勒县| 永靖县| 政和县| 凤阳县| 鄂托克前旗|