It depends on the use case. If you don’t need to return a new array, use forEach and whenever you need to return a new array or mutate the currently existing one, use map
, filter
, reduce
.
It depends on the use case. If you don’t need to return a new array, use forEach and whenever you need to return a new array or mutate the currently existing one, use map
, filter
, reduce
.
Written by