3 ms·
Ironically, the .map example is actually a bit of a waste. A better function in that case is to use .filter: .map really should be used when your resultant arra
by electrichead 13y ago
Ironically, the .map example is actually a bit of a waste. A better function in that case is to use .filter: .map really should be used when your resultant array is the same length as the initial array, except with different elements i.e. [1,2,3,4] to [2,4,6,8], where the same function was applied to each element. For array manipulation, it is often better to use underscore.js
Edit: I just read the bit about how grep was better than your .map usage. I still think filter is better than grep in a lot of cases, esp. when you are trying to chain methods when working with an array of (jQuery) elements