Defining functions

A common way to define a function is with a function type expression.

After the keyword function, the unique name of the function is specified, followed by a description of the inputs that it takes (called parameters). For each parameter, the data type specifies the allowed input values (called arguments).

Loading TypeScript...

A function can have multiple parameters, separated by a comma (,).

Loading TypeScript...

Parameter types allow TypeScript to produce a compilation error when a function is being used incorrectly.

Was this page helpful?