1var users = { 'fred': { 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 }};
2
3_.mapValues(users, function(o) { return o.age; });
4// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
5
6// The `_.property` iteratee shorthand.
7_.mapValues(users, 'age');
8// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
1const _quote_filter = _.map(quote_state, (val, key) => { if (val) { return key }})console.log(_quote_filter) //=> [ 'btc', undefined, undefined ]
1function square(n) {
2 return n * n;
3}
4
5_.map([4, 8], square);
6// => [16, 64]
7
8_.map({ 'a': 4, 'b': 8 }, square);
9// => [16, 64] (iteration order is not guaranteed)
10
11var users = [
12 { 'user': 'barney' },
13 { 'user': 'fred' }
14];
15
16// The `_.property` iteratee shorthand.
17_.map(users, 'user');
18// => ['barney', 'fred']
1const _markets_arr = []
2
3_.map(markets, (val, key) => {
4 val.symbol = key
5 if (val.buys > 0) {
6 _markets_arr.push(val)
7 }
8})
9
10console.log(_markets_arr)
11//=> [
12 { buys: 3, sells: 1, symbol: 'DASH/BTC' },
13 { buys: 3, sells: 2, symbol: 'ETH/BTC' }
14 ]