Skip to content

Commit 60c0c6b

Browse files
committed
Update README.md
1 parent e024d4b commit 60c0c6b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,20 @@ type X = {
233233

234234
## Q. What is Rest parameters?
235235

236-
The rest parameter is used to pass zero or more values to a function. It is declared by prefixing the three **dot** characters **('...')** before the parameter. It allows the functions to have a variable number of arguments without using the arguments object.
236+
The rest parameter is used to pass zero or more values to a function. It is declared by prefixing the three **dot** characters **('...')** before the parameter. It allows the functions to have a variable number of arguments without using the arguments object.
237237

238238
**Rules**:
239239

240240
* Only one rest parameter is allowed in a function.
241241
* It must be an array type.
242242
* It must be a last parameter in the parameter list.
243243

244+
**Example:**
245+
244246
```ts
247+
/**
248+
* Rest parameters
249+
*/
245250
function sum(a: number, ...b: number[]): number {
246251
let result = a;
247252
for (var i = 0; i < b.length; i++) {

0 commit comments

Comments
 (0)