Creating Default Function Parameters in Javascript


Provide default values for function parameters.

Source Code

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