Difference
between jQuery .map and .each
- S.NojQuery.map()jQuery.each()
1 Used as:
The map method can be used as an iterator.Used as:
The each method is meant to be used as an immutable iterator.2 What it returns ?
Map function returns a new arrayWhat it returns ?
Each function returns the original array.3 Callback arguments used:
map(arr, function(elem, index) {});Callback arguments used:
each(arr, function(index, elem) {});
Note:
If we overuse the return value
of the map function we can potentially waste a lot of memory.
No comments:
Post a Comment