This works:
const { foo, bar } = someFunc();
And so does this:
let { foo, bar } = someFunc();
But if I try to destructure into already declared variables...
let foo = 0;
let bar = 0;
{ foo, bar } = someFunc();
then:
Uncaught SyntaxError: Unexpected token =
Is this by design? Is there a workaround other than declaring a temp object to receive the value? I'm doing this in a switch/case statement; foo and bar are declared on top and used after the switch. So far I can only do:
const temp = someFunc();
foo = temp.foo;
bar = temp.bar;