I have one complex object and want to extract some keys and apply some function and assign it with some other variable name and using object destructuring syntax but couldn't find any solution to apply.
const alpha = { a: 'lower', b: '23.45' };
const { a: newA.toUpperCase(), b: parseFloat(floatB)} = alpha;
I know this is wrong because here newA
and floatB
is yet not defined.
Even I tried
const { a:a.toUpperCase(), b: parseFloat(b)} = alpha;
But that also not work
So my question is how can we achieve somehow.
Or we need to do it later once assign as new variable name?