Expressions as Default Values

Learn how to use expressions as default parameters, compute the value of default parameters from other parameters, and use the default value for rest parameters.

The default values are not limited to literals. Expressions are welcome as well, and which is quite powerful. Kudos to JavaScript for that.

In the following code, the fileTax() function needs a filing date. If the caller does not provide it, the current date of execution is assumed as the default value.

Get hands-on with 1200+ tech skills courses.