Default Parameters for Functions
For functions in JavaScript you can define a default value for a parameter for handling the case where a parameter is not provided, falling back to the dafault.
const greeting = (title = 'World') => {
return `Hello, ${ title }!`;
};
console.log(greeting());
module.exports = { greeting }
So when greeting
is invoced without any parameters like so: console.log(greeting());
it will emit the interpolated string:
$ node helloworld.js
Hello, World!