Setting Default Parameter Values in Functions in Javascript


Set default values for function parameters to avoid undefined values.

Source Code

function greet(name = 'Guest') {
  console.log(`Hello, ${name}!`);
}
greet();
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments