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
2
u/Solonotix Jul 17 '26
That's the real problem. Don't repeat yourself. If you have a complex data structure that needs validation, write a class with a constructor that handles it. If you get something that isn't that class, send it through the constructor. Hell, if you're completely opposed to classes, you could technically just write a class-like function, but in my personal experience I very much like the convenience of a simple
instanceofcheck.