Parameters are separated by comma. There are positional, optional and rest parameters.
: like
Example:
function x(a, b : string) {}The function has two parameters. The second parameter has a type annotation, which indicates that the function must be called with a value of the specified type. (Se like for explanation of the
like-constraint).
: like =An optional parameter is provided with a default value. If a value is not provided in the method call, the parameter gets the default value.
function x(c = 100) { return c; } x(17); // returns 17 x(); // returns 100
...
The rest parameter becomes an array of all arguments in excess of the ones that matches other parameters. Example:
function x(...d) { return d.length; } x(1,2,3); // returns 3 x(); // returns 0
A rest parameter must always be the last parameter in the parameter list.
