The answer
The missing parameters are set to undefined. You can handle this with default parameters, which apply only when the argument is undefined or omitted.
The missing parameters are set to undefined. You can handle this with default parameters, which apply only when the argument is undefined or omitted.
No. Defaults apply only when the argument is undefined or omitted. Passing null, 0, or empty string does not trigger the default, because those are real values.
undefined. If a function has no return, or a return with no expression, it returns undefined to the caller.
Check if the parameter === undefined, or use a default parameter. You can also check arguments.length (in regular functions) to see how many arguments were actually passed.
Browse all our FAQs or reach out to our support team
Your learning library
Find your next course. Build something great.