r/javascript • u/bogdanelcs • Jul 16 '26
I stopped destructuring everything
https://allthingssmitty.com/2026/07/13/i-stopped-destructuring-everything/
84
Upvotes
r/javascript • u/bogdanelcs • Jul 16 '26
View all comments
Show parent comment
1
u/azhder Jul 16 '26
Let’s see, you write a function like this:
({ user = {} }) => {
console.log( user.id );
}
And somewhere somehow down the line the requirements change, some other part of the code changes and instead of undefined, the user is null…
The way I wrote the first time with the ?? will not blow up if a null is passed.