4
hinst
4y

People who use destructuring assignment EVERYWHERE; why you do this to me?

In most cases it does not even reduce code length. Like

{ field } = object
save(field)

Why no just type

save(object.field)

Tis' hard to understand

Comments
  • 4
    Benefits are multiple.
    You can see the properties that are used all in one place.
    You DO reduce redundant code. The example you gave is redundant but usually you use more than one prop.
    You can alias properties, which allows short syntax in property assignment somewhere else.

    I could go on but in many cases except your given it does make sense. Dont you like it as well? This is the syntactic sugar other languages dream of.
  • 2
    I prefer the OP‘s way with object property access, bc it‘s clearer and easier to read and understand.
    Readability is the key to a good codebase.
  • 0
    @Pierreburton91 if you need an external tool to understand the origin of shit you're working with, then you are doing something VERY wrong
  • 0
    @Pierreburton91 using an IDE search is already an external tool. If you cannot just look at the code and understand it without hopping around then the code is a fucking pile of spaghetti.
Add Comment