Function parameters

A parameter is a variable that stores a value which was passed into the execution of a function.

A parameter can be assigned a default value.

Notice that TypeScript automatically infers the parameter type from the default value.

If we had not specifically added the LogLevel type to the level parameter, the parameter type would have been inferred as string.

Was this page helpful?