While performing object destructuring it is possible to provide default values if the key does not exist (i.e. undefinedKey).
If the (string) key does exist, it does not get overwritten (even if empty).
I'm wondering if it's possible to specify an override for an empty string while destructuring. In the example below, I would like emptyKey to print Override for empty key
const testObject = {
emptyKey: '',
filledKey: 'Some Initial Value',
};
const {
emptyKey = 'Override for empty key',
filledKey = 'Override for filled key',
undefinedKey = 'Override for undefined key',
} = testObject;
console.log(emptyKey); //''
console.log(filledKey); //'Some Initial Value'
console.log(undefinedKey); //'Override for undefined key'
||comparisons where the value is used, but I hope there is a cleaner way.