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