I am trying to get a better understanding of the jQuery.map function.
So in general terms .map takes a array and ‘maps’ it to another array of items.
easy example:
$.map([0,1,2], function(n){ return n+4; });
results in [4,5,6]
I think I understand what it does. I want to under why would someone need it. What is the practical use of this function? How are you using this in your code?
$.mapis all about converting items in a set.As far as the DOM, I often use it to quickly pluck out values from my elements:
The above converts the
<label>elements inside a list of users to just the text contained therein. Then I can do: