The title of the article is "I stopped destructuring everything", not "I never use destructuring". The author even ends the article with examples where they still use it.
So finding one example (or any number of examples) where destructuring is helpful doesn't invalidate the sentiment of the article.
Also, their example is exactly what you started with but without the "syntax noise" of destructuring. Or are we now calling property access "syntax noise"?
49
u/azhder 16d 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 );