- 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程序設計與開發
- Designing Machine Learning Systems with Python
- 從零開始:數字圖像處理的編程基礎與應用
- 軟件界面交互設計基礎
- 從程序員到架構師:大數據量、緩存、高并發、微服務、多團隊協同等核心場景實戰
- Python網絡爬蟲從入門到實踐(第2版)
- Hands-On C++ Game Animation Programming
- Java軟件開發基礎
- Java EE核心技術與應用
- Building Android UIs with Custom Views
- Kotlin極簡教程
- ActionScript 3.0從入門到精通(視頻實戰版)
- iOS開發項目化入門教程
- Java多線程并發體系實戰(微課視頻版)
- Building a Media Center with Raspberry Pi