DEV Community

Cover image for Interview Questions Frontend 2020
Liran meir
Liran meir

Posted on

Interview Questions Frontend 2020

javascript map vs foreach? - whats the difference

in short..

map returns a new array based on the callback
<>
foreach doesn't return but can change the original array

map can be chained with .filter and other chaining methods
<>
foreach doesn't

map is 3 times quicker
<>
foreach is slower

Top comments (0)