- 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.
推薦閱讀
- 圖解Java數據結構與算法(微課視頻版)
- 算法精粹:經典計算機科學問題的Java實現
- R語言游戲數據分析與挖掘
- NativeScript for Angular Mobile Development
- PostgreSQL Replication(Second Edition)
- QGIS:Becoming a GIS Power User
- Mastering Unity 2D Game Development(Second Edition)
- C#程序設計基礎入門教程
- Python GUI Programming Cookbook(Second Edition)
- 實戰Python網絡爬蟲
- Developing Java Applications with Spring and Spring Boot
- Java程序設計教程
- Spark for Data Science
- 編譯原理學習與實踐指導
- 計算機信息技術實踐教程