lodash get state code example
Example 1: lodash find object in array
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false },
{ 'user': 'pebbles', 'age': 1, 'active': true }
];
_.find(users, function(o) { return o.age < 40; });
// => object for 'barney'
Example 2: 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);