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.
- How to create default function parameter in PHP?
- HTML | DOM Parameter value Property
- HTML | DOM Parameter name Property
- HTML | DOM Parameter Object
- Argument vs Parameter in Java
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.