Setting Default Parameter Values in Javascript


Set 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