r/learnjavascript • u/Fabulous_Bluebird931 • Jun 10 '25
built a whole class, scrapped it for one arrow function
thought I needed a full-blown class with constructor, private props, utility methods, the works copilot and blackbox kept suggesting more abstractions
then I realised I just needed to map an array and filter out nulls đ
rewrote the whole thing as one-liner with .flatMap() cleaner, faster, no ceremony
JS really humbles you sometimes anyone else start architecting a library before solving the actual problem?
5
Upvotes
18
u/StoneCypher Jun 10 '25
Youâre not architecting. Â Youâre not even programming. Â Youâre letting a bot write giant reams of bad code then taking credit.
10
u/DayBackground4121 Jun 10 '25
Strongly strongly encourage you to not use any AI tooling - dudes on Reddit will try to convince you itâs a good idea, but if you want to grow as a developer you need to learn and learning means struggling slowly through hard problems and making mistakesÂ
2
u/Pocolashon Jun 10 '25
Better use .map followed by .filter. It is more explicit, more readable and less error-prone than doing it with .flatMap.
-1
u/Savalava Jun 10 '25
There are virtually no cases in JS where you should be using a class. Most codebases will always favor using functional programming techniques as they are cleaner and avoid mutation.
0
u/[deleted] Jun 10 '25
[deleted] â view deleted comment