Alain, thanks for your answer. It's really clear and enriching.
Hi Maxime,
Note that the following is specific to JS. It may work similar or quite different in other languages.
To answer your question, try the following code
[1,2,3,4,5] .map(x => { console.log("A", x); return x; }) .map(y => console.log("B", y))
This outputs
A 1 A 2 A 3 A 4 A 5 B 1 B 2 B 3 B 4 B 5
That shows that in JS, a regular array map operation iterates over the entire array before passing it on to the next operation.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Alain, thanks for your answer. It's really clear and enriching.
Hi Maxime,
Note that the following is specific to JS. It may work similar or quite different in other languages.
To answer your question, try the following code
This outputs
That shows that in JS, a regular array map operation iterates over the entire array before passing it on to the next operation.