I would like to clarify that, regarding point 1, map() and forEach() do not expect the same type of functions. forEach() expects a function that takes in one argument and returns nothing. Passing in the function x => x * x wouldn't even be valid in many other languages with a similar function. map() instead expects a function that takes in one argument and returns a new value of any type.
x => x * x
Since forEach() is a void function (undefined in JS) it should preferably only be used for IO operations where no return value is expected (eg. changing the DOM or printing to console).
Thanks, for your comment I intentionally use the same example for both map and forEach to just not confuse folks. But, if you read my final thought, you'll see that map is all about transforming data, and this example should be done with map.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.