// Default parameters let you assign a default value to a parameter when you define a function. For example:
function greeting(name, message = ”Hello”){
console. log(`${messgae} ${name}`)
}
greeting(‘John’); //output: Hello John
//you can also assign a new value to the default parameter
//when you call the function
greeting(‘Doe’, ‘Hi’); //output: Hi Doe
// Default Parameter Values in javascript
// Longhand:
function volume(l, w, h) {
if (w === undefined)
w = 3;
if (h === undefined)
h = 4;
return l * w * h;
}
console.log(volume(2)); //output: 24
// Shorthand:
volume_ = (l, w = 3, h = 4 ) => (l * w * h);
console.log(volume_(2)) //output: 24