what would be an appropriate way to write
foo
to achieve this?
If you mean to default only when there is no parameter passed to the function call, then you need to check the arguments
length, or to spread the arguments if you want to keep an arrow function.
const foo = (...args) => {
const bar = args.length ? args[0] : "";
console.log(bar)
}
foo(null) // null
foo(undefined) // undefined
foo(); // ""