Answers for "javascript function required arguments"

1

javascript function required arguments

const isRequired = () => { throw new Error('param is required'); };

const hello = (name = isRequired()) => { console.log(`hello ${name}`) };

// This will throw an error because no name is provided
hello();

// This will also throw an error
hello(undefined);

// These are good!
hello(null);
hello('David');
Posted by: Guest on January-01-2021

Code answers related to "javascript function required arguments"

Code answers related to "Javascript"

Browse Popular Code Answers by Language