Let us first take a look at a problem and then we’ll take a look at how default values for function parameters address that problem.
Let’s first create a simple function.
Because the function is trying to multiply two things that are not a number.
Traditionally, you would pass values in the function but it is much simpler to establish a default value and you do it as a part of the parameters in the function.
Example 3: Now try by putting in values 10 and 100.
- HTML | DOM Parameter Object
- Argument vs Parameter in Java
- Python | file parameter in print()
- C# | Default Constructor
- CSS | :default Selector
- HTML | default Attribute
- How to set the default value for an HTML <select> element?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.