I need to do ES6 Destructuring Assignment repeatedly:
- Define variables from Destructuring Assignment
- Update variables from Destructuring Assignment repeatedly
Like:
function margin() {
const left=1, right=2, top=3, bottom=4;
return { left, right, top, bottom };
}
let { left, bottom } = margin();
// later, need to update left, bottom again:
{ left, bottom } = margin();
How to make the above code work?
I'm getting Unexpected token
when updating the variables again.
I know putting them all into a single variable will do, but the question focus on whether it is possible to use Destructuring Assignment repeatedly.