Object so nice I destructured it twice!
I learned today that you can destructure javascript object keys multiple times:
const obj = {a: 1};
const {a: c, a: d} = obj;
c === d
// evaluates to true
This is nice when you want to destructure specific keys for convenience but still need to operate on the whole object, like this:
const {bigObj, bigObj: {isError}} = deepObj;
Tweet