The functions map, filter and reduce are definitely not es6 specific; and ES6 is anyway almost 5 years old.
They exist in almost every major language; in Java they are in the Streams API, in Python they are omnipresent, often used as list comprehensions, in Scala they are there, in Rust they are present in the standard library.
And by using them, you are extremely explicit about what is happening: if you use map, you are doing that and only that. With a for loop, instead, you might be using the for loop to map elements, or to filter them, or to reduce, and one would have to read the details to understand what exactly you are doing. This can take time, especially in larger applications.
Therefore, I argue that e.g. saying map instead of filteris more specific than writing a generic for loop that looks almost the same in the two cases.
It also results in less lines of code, and respects immutability, which in turn helps reducing the average number of bugs in the application.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The functions
map
,filter
andreduce
are definitely not es6 specific; and ES6 is anyway almost 5 years old.They exist in almost every major language; in Java they are in the Streams API, in Python they are omnipresent, often used as list comprehensions, in Scala they are there, in Rust they are present in the standard library.
And by using them, you are extremely explicit about what is happening: if you use
map
, you are doing that and only that. With a for loop, instead, you might be using the for loop to map elements, or to filter them, or to reduce, and one would have to read the details to understand what exactly you are doing. This can take time, especially in larger applications.Therefore, I argue that e.g. saying
map
instead offilter
is more specific than writing a generic for loop that looks almost the same in the two cases.It also results in less lines of code, and respects immutability, which in turn helps reducing the average number of bugs in the application.