Optional Parameters

Learn how to declare functions with optional parameters.

We'll cover the following

When you want to leave the passing of arguments to functions as an option, you can use optional parameters.

A function can have two types of parameters: required and optional. The required parameters are listed first, followed by any optional parameters. Optional parameters can be named or positional.

Optional parameters can either be named or positional, but not both.

Create a free account to access the full course.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy