.map() is designed to both iterate and create a new resulting array.

.each() is designed to be an iterator (no new array created).

Either will work for plain iteration, though I would argue that the intent of your code is clearer if you are just doing an iteration if you use .each() since that is its intended and only purpose.

As for functionality differences besides the creation of the array, jQuery's .each() allows you to terminate the iteration by returning false from the callback. jQuery's .map() does not have a way to terminate the iteration.



source -  http://stackoverflow.com/questions/22519351/jquery-each-vs-map-without-return



Posted by linuxism
,