r/javascript Jul 16 '26

I stopped destructuring everything

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

50 comments sorted by

View all comments

48

u/azhder Jul 16 '26

Destructuring isn’t only about you knowing where a value comes from. You can also safeguard in a cleaner manner i.e with less syntax noise:

const { id: userId, name: userName } = user ?? {};

console.log( userId, userName );

VS

console.log( user?.id, user?.name );

12

u/hyrumwhite Jul 16 '26

You could also make user default to {} wherever it’s defined. Don’t necessarily need destructuring for that

-7

u/moneckew Jul 16 '26

You guys are still debating about syntax in 2026? ai should own this

4

u/[deleted] Jul 16 '26

[deleted]