Skip to content

Latest commit

 

History

History
74 lines (68 loc) · 2.69 KB

rest-parameter.md

File metadata and controls

74 lines (68 loc) · 2.69 KB

Rest Parameter aka Variadic Parameter

A rest parameter or variadic parameter is an optional parameter that goes on the end of a function.

In Typescript, they're called rest parameters. Many other languages call them variadic parameters instead.

For example:

// `inN` is a rest parameter
function concat(in1: string, in2: string, ...inN: string[]) {
    return in1 + in2 + inN.reduce((acc, val) => acc + val);
}

We use rest parameters for user-supplied functional options.