|
|
|
|
|
by knallfrosch
673 days ago
|
|
Disagree on this. filter and map are much more readable and especially extensible than result-arrays. Plus it eliminates out-of-bonds indexing. See the variable name. It's forced to be 'result' so that it's consistent with the result-array style. Therefore it lacks a descriptive name. For the functional methods, you can easily assign the filter(age > 18) result to an intermediate variable like adultUsers to make the code even more descriptive. Useful when you have more steps. With the result-array approach, you'd have to repeat the looping code or bury the description deep in the loop itself and so you usually avoid that. |
|
That’s down to preference.
Doesnt both filter and map copy the array increasing gc pressure?