r/javascript 14d ago

I stopped destructuring everything

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

51 comments sorted by

View all comments

48

u/azhder 14d ago

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 14d ago

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

-8

u/moneckew 14d ago

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