Example 1: lodash unique array of objects
var users = [
{id:1,name:'ted'},
{id:1,name:'ted'},
{id:1,name:'bob'},
{id:3,name:'sara'}
];
var uniqueUsersByID = _.uniqBy(users,'id');
var uniqueUsers = _.uniqWith(users, _.isEqual);
Example 2: lodash unique array
_.uniq([2, 1, 2]);
_.uniq([1, 1, 2], true);
_.uniq([1, 2.5, 1.5, 2], function(n) {
return this.floor(n);
}, Math);
_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
Example 3: lodash deep clone object
const clone = require('lodash/clone');
const cloneDeep = require('lodash/clonedeep');
const shallowCopy = clone(originalObject);
const deepCopy = clonedeep(originalObject);
Example 4: lodash find duplicate element index
const _ = require('lodash');
let arr = ["a", "a", "b", "c", "c", "a"];
let result = _.omitBy(
_.reduce(arr, (a, v, i) => _.set(a, v, (a[v] || []).concat([i])), {} ),
v => v.length <= 1
);
console.log(result);
Example 5: lodash map
_.each(markets, (obj, key) => { obj.symbol = key})console.log(markets)