Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
map transforms each item into a new array, filter selects matching items into a new array, and forEach runs callbacks and returns undefined.
For [1, -2, 3], map(n => n * 2) returns [2, -4, 6], while filter(n => n > 0) returns [1, 3]. forEach is useful for side effects and returns undefined rather than collected callback results. map and filter do not directly mutate the source array, but a callback can still mutate referenced objects or other state.