- 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 Hyper-V Solutions
- The React Workshop
- Web Application Development with MEAN
- Java持續交付
- 編譯系統透視:圖解編譯原理
- Kali Linux Wireless Penetration Testing Beginner's Guide(Third Edition)
- 從0到1:Python數據分析
- 深入RabbitMQ
- Scientific Computing with Scala
- 批調度與網絡問題的組合算法
- jQuery炫酷應用實例集錦
- Mastering Python Design Patterns
- Go語言開發實戰(慕課版)
- Oracle數據庫編程經典300例