Default Values
Definition
Default values are values that are taken up by the parameters of a function when no corresponding argument is passed into the function call.
We can assign default values to parameters using the syntax:
function funcName(parameter1 = value1, parameter2 = value2, …) {
// your code here …
}
Example:
12345function sum(a = 5, b = 10) { return a + b; } console.log(sum()); // Output: 15
1. What happens if a function parameter has a default value and no argument is passed for it in the function call?
2. What will be the output of the following code?
3. What will be the output of the following code?
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 54
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 1.33
Default Values
Glissez pour afficher le menu
Definition
Default values are values that are taken up by the parameters of a function when no corresponding argument is passed into the function call.
We can assign default values to parameters using the syntax:
function funcName(parameter1 = value1, parameter2 = value2, …) {
// your code here …
}
Example:
12345function sum(a = 5, b = 10) { return a + b; } console.log(sum()); // Output: 15
1. What happens if a function parameter has a default value and no argument is passed for it in the function call?
2. What will be the output of the following code?
3. What will be the output of the following code?
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 54