In Javascaript, I publicly assigned the variable A. I now want to assign A to a destructured variable. But all I can think of is:
const {variable} = getVariable();
A = variable;
How can I make this into a one-liner?
In Javascaript, I publicly assigned the variable A. I now want to assign A to a destructured variable. But all I can think of is:
const {variable} = getVariable();
A = variable;
How can I make this into a one-liner?
You can write
({variable: A} = getVariable());
if you insist on using destructuring to assign a previously declared variable, but really there's no good reason to use destructuring here. Normal property access is so much simpler, shorter, and more readable:
A = getVariable().variable;
You can do this
const {variable:A} = getVariable();