DEV Community

Discussion on: Default Function Parameters (ES6)

Collapse
 
cipak profile image
Ciprian Șerbu
If you don't specify an argument, the default value of the parameters gets used.

What if I specify an argument with an undefined value?

Collapse
 
akashkava profile image
Akash Kava

undefined logically means that you are not specifying the argument. So it will use default value.

Collapse
 
runosaduwa profile image
Runo-saduwa

Good question!!, the same thing applies. The only difference in this case is that you are explicitly setting your argument to be undefined. The trick here is, whether you specify undefined explicitly or allow JavaScript to do it for you implicitly, the important thing to note is that once JavaScript reads undefined it uses the default parameters