28.
How are default parameters defined in JavaScript functions?
By using the "default" keyword after the parameter.
By assigning a value to the parameter in the function declaration.
By declaring the parameter value inside parentheses.
By using the "default" keyword before the parameter value.
Correct: B
Default parameters in JavaScript functions are defined by assigning a value to the parameter in the function declaration. If no argument is passed when the function is called, the default parameter value will be used instead. Example:
function multiply(a, b = 1) {
return a * b;
}
console.log(multiply(5)); // Output: 5 (b defaults to 1)
console.log(multiply(5, 3)); // Output: 15 (b is provided as 3)