- 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.
推薦閱讀
- JavaScript全程指南
- Java 9 Concurrency Cookbook(Second Edition)
- R語言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- Scratch 3.0少兒編程與邏輯思維訓(xùn)練
- Data Analysis with IBM SPSS Statistics
- Oracle JDeveloper 11gR2 Cookbook
- 劍指Java:核心原理與應(yīng)用實(shí)踐
- 區(qū)塊鏈底層設(shè)計(jì)Java實(shí)戰(zhàn)
- Building Serverless Architectures
- Learning Nessus for Penetration Testing
- Python一行流:像專家一樣寫代碼
- Python計(jì)算機(jī)視覺與深度學(xué)習(xí)實(shí)戰(zhàn)
- 零基礎(chǔ)PHP從入門到精通
- 深度學(xué)習(xí):基于Python語言和TensorFlow平臺(視頻講解版)
- 情境微課開發(fā)(第2版)