Default Parameter Value
Multiple Choice Easy
Question
In function f(x = 5) { return x; }, what does f() return?
Hint
Default params kick in when the argument is missing.
Explanation
When f() is called with no arguments, the default parameter value 5 is used for x. So f() returns 5. Default parameters only apply when the argument is undefined or missing, not when it is explicitly null or other falsy values.
Related Resources
Related Lessons
- Functions
Learn how functions work in programming.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.