function greet(name = 'vizitator') {
console.log(`Salut, ${name}!`);
}
greet();The call without an argument uses the “vizitator” default.
LESSON 30 OF 50
Provide a fallback when the call supplies no argument.
A parameter initializer is evaluated when the corresponding argument is missing or undefined. This gives the function a clear fallback without repeated checks in its body.
function greet(name = 'vizitator') {
console.log(`Salut, ${name}!`);
}
greet();The call without an argument uses the “vizitator” default.
function greet(name) { console.log(`Salut, ${name}!`); }
greet();Without an initializer, name becomes undefined and the message is not the intended one.
Declare greet with the default name “vizitator”, build the message and call the function without an argument.
Run the code to see the result.The parameter initializer supplies the value before the body builds the message.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.