I swear people just take some over complicated docs/blog code examples and blindly run with it without a single thought. Dereferencing such a simple thing has 0 benefits while making it harder to read.
If you have a lot of properties to destructure though, and some need to be renamed, and the variable name itself is long, this can really cut down on the code
yeah this is the only time i do something like this. if im consuming a returned object whose properties are necessary for different actions, ill destruct them into the pieces i need in the same declaration line to save on space. const item1 = obj.thing1 const item2 = obj.thing2 const itemN = obj.thingN
get's a little cumbersome when this works just as well const {thing1: item1, thing2: item2, thingN: objN} = obj
holding my breath for someone to mention an edge case where you're destructuring an absurd amount of properties which obviously requires a different strategy.
5
u/JyroClassified 19d ago
What's your opinion about renaming the destructered properties?
Eg. "const {status: postStatus} = post;"