Javascript - Default Parameters
📖 Read the lesson
Code Life
By Pierre Marsaa
A Value When Nothing Is Passed
Remember: a parameter without an argument is
undefined
. That gives awkward messages:
↗️
Loading editor...
↶
▶️ Run
↷
A
default parameter
fixes this: write
= value
after the parameter name. That value is used whenever no argument is passed.
↗️
Loading editor...
↶
▶️ Run
↷
Verify