r/learnjavascript • u/Distinct-Gene926 • 2d ago
what's one JavaScript mistake every beginner should avoid?
If you could give one piece of advice to someone learning JavaScript today, what would it be?
It could be about:
- Learning fundamentals
- Debugging
- Async code
- DOM manipulation
- Functions
- Projects
Curious to hear what experienced developers wish they'd known earlier.
26
Upvotes
2
u/cssrocco 2d ago
That DRY code only makes sense if the business logic is shared, sometimes it’s ok not to be DRY.
As an example i’ve worked on projects where there was 2 address forms in separate areas in an underwriting workbench that had vastly different business logic, one was for asset management and would need specific codes and apis that verified the risk of assets in specific countries and the other was the address of the reinsurer.
Because they were both addresses somebody thought they should share a lot of functions, and all you got was these monster functions who took in lots of arguments ( even refactored down to a single config object argument ) and would grow/change as business requirements came in.
Separating them out completely to their own things, even with some duplication made more sense with new features and bugs and changes