Recently I held a short lecture on the use of functions in Javascript, and how it’s possible to use functionality like map, reduce, filter and Javascript’s amazing variable context. I prefer to useunderscore.js so that I can use the wonderful functionality even on old browsers.
Lets start easy with _.map. Map is easy, what it does is take an input array, send each element into a function, and putting the result in a result array. The resulting array contains mapped versions of each element in the input array.