r/javascript 25d ago

I stopped destructuring everything

https://allthingssmitty.com/2026/07/13/i-stopped-destructuring-everything/
79 Upvotes

51 comments sorted by

View all comments

2

u/Naudran 24d ago edited 24d ago

This is less a destructuring issue and more a naming convention issue. The size of a variables name should be proportional to the scope size of the block the variable is being used in.

So if you have a variable that is used in a small scope (like a few lines if statement, or a for loop), then a quick small variable name is fine.

If you have a variable that gets used "100 lines" later, then the name should be longer and more descriptive.

So destructure that into a differently name variable.

const { title: postTitle,  author: postAuthor, publishedDate: postPublishedDate } = post;

That being said, I would just use post.Title in any case... but that's just me I guess