Hacker News new | ask | show | jobs
by ajhurliman 2323 days ago
Except that push mutates the array in question and concat returns a deep copy. And forEach returns undefined, while map returns an array. If someone claimed they were the same in an interview I doubt they would get hired.
2 comments

Technically, yes there is a difference in semantics and convenience. pragmatically it depends on the programming style and language features / expressiveness.

Developers were able to map from one list to another list using for loops before functional-style map-like functions. Map is just semantically more concise about what it’s doing, rather than how.

As for mutation versus immutable copy behavior, that’s for convenience. Developers can also clone collections themselves.

A more charitable means of evaluating the class lead’s comment is that the core of an algorithm is not affected by these things.

One could argue multiplication is just repeated addition.

Do you mean a shallow copy?