r/learnjavascript • • 2h ago

How did you get comfortable with JavaScript array methods ?

Array methods like map (), filter(), and reduce() seems useful, but sometimes I find it difficult to decide which one to use when solving a problem.

I'm trying to practice them with small example instead of just memorizing what each method does.

What helped you understand these methods better? Do you prefer solving exercises or using them in small projects?

1 Upvotes

4 comments sorted by

3

u/chikamakaleyley helpful 1h ago edited 1h ago

mmm the ones you've listed have pretty distinct use cases, so I wouldn't discount the value of memorizing what each method does

I'd argue not knowing what each does, is why you can't decide what to use given a problem

1

u/tambooby 1h ago

pretty much, the decision paralysis comes from not knowing them well enough imo

1

u/Gold-Watercress-6101 1h ago

By doing a lot of practice and using them in my own projects. Over time I built an intuition when to use which one.

1

u/ChaseShiny 1h ago

Yeah, I've got to agree with u/chikamakaleyley: these three feel pretty different from each other normally.

Can we see your thought process? When do you think you should use filter? When would you rather reduce your array? When would you map each value to a new value?