Default parameters allow you to set default values for function parameters if no argument is provided when calling the function. This helps in avoiding undefined
values.
Example:
function greet(name = 'Guest') {
console.log('Hello, ' + name);
}
greet(); // Output: Hello, Guest
greet('John'); // Output: Hello, John
Tags: intermediate, JavaScript, Functions
URL: https://www.tiktok.com/@jsmentoring/photo/7470673054704635158