function x({ name = 'abc' }) {
console.log(name);
}
x({ name: null })
How to provide default value for above case which handles all falsey value for name? I was expecting that when name: null will be replaced by abc but apparently not the case? It's only working in the below case
function x({ name = 'abc' }) {
console.log(name);
}
x({ })
Wondering if it's possible to provide default value for all falsey value? Of course we can check for the condition explicitly but wondering if there is any alternatives
name = name || 'abc'? As long as name is falsey it will work, though it will work with''as well, which might not be intended.