let text, value;
if (typeof f == 'string') {
text = value = f;
} else {
let {
text, value
} = f;
}
Doing this creates two new vars (from the else
), however if I write it like so:
let text, value;
if (typeof f == 'string') {
text = value = f;
} else {
{
text, value
} = f;
}
I receive a syntax error. What is the best approach here?