What is the difference between map() and forEach()?
Method Returns Chainable Use Case
forEach
undefin
❌ No Iteration
map() New array ✅ Yes Transformation
Example:
[1,2,3].map(x => x*2); // [2,4,6]
Method Returns Chainable Use Case
forEach
undefin
❌ No Iteration
map() New array ✅ Yes Transformation
Example:
[1,2,3].map(x => x*2); // [2,4,6]