Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Iteration Basics - map() vs forEach()
What is the key difference between map() and forEach()?
Answer options
- map() is faster
- forEach() can be stopped, map() cannot
- There is no difference - they work identically
- map() returns a new array, forEach() returns undefined
Show the answer
Correct answer:
- map() returns a new array, forEach() returns undefined