Answers for "lodash unique array"

2

lodash unique array

_.uniq([2, 1, 2]);
// => [2, 1]
 
// using `isSorted`
_.uniq([1, 1, 2], true);
// => [1, 2]
 
// using an iteratee function
_.uniq([1, 2.5, 1.5, 2], function(n) {
  return this.floor(n);
}, Math);
// => [1, 2.5]
 
// using the `_.property` callback shorthand
_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]
Posted by: Guest on February-21-2021
1

lodash map

const _quote_filter = _.map(quote_state, (val, key) => {   if (val) {      return key   }})console.log(_quote_filter) //=> [ 'btc', undefined, undefined ]
Posted by: Guest on May-12-2020
-1

lodash map

const _markets_arr = []

_.map(markets, (val, key) => {
   val.symbol = key
   if (val.buys > 0) {
      _markets_arr.push(val)
   }
})

console.log(_markets_arr)
//=> [ 
       { buys: 3, sells: 1, symbol: 'DASH/BTC' },
       { buys: 3, sells: 2, symbol: 'ETH/BTC' } 
   ]
Posted by: Guest on May-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language