Modern JavaScript
About Lesson

In this JavaScript lesson we are going to talk about JavaScript Default Parameters, It is used for adding default values to function parameters if no value or undefined is passed. also it is JavaScript ES6 feature.



For example we have a function that takes two parameters, if you see this code you will receive 11 in the output.



But what if we just add one parameter, if you see our function expects two parameters, if we give one parameter you will receive NaN in the output.


To solve this problem we can use ES6 default parameters, let’s take a look at this example.


In this example for the second parameters we have added a default value, now if we add just one value, there will be no problem, because it will take the default parameter as second value.



This is the second example and we have used multiple default parameters.

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found