Aaah I see – I tried using computed property names while destructuring before, but it never worked because I tried it without assigning to an alias. (so just const { [foo] } = bar; – makes sense that this doesn't work now that I think about it)
Very nice to know that it works when using an alias, thanks!
8
u/darrenturn90 Apr 28 '19
It does seem inconsistent especially when you use as in what is essentially destructuring an import / export ie {default as foo}
Another thing to keep in mind also you can use [value] in destructuring to get the key referred to in the value variable from the destructured object