lodash find element in array code example
Example 1: lodash deep clone object
const clone = require('lodash/clone');
const cloneDeep = require('lodash/clonedeep');
const shallowCopy = clone(originalObject);
const deepCopy = clonedeep(originalObject);
Example 2: 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; });
Example 3: lodash find all in array
const allInarray = array.filter(item => item === compare)
Example 4: get lodash
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.get(object, 'a[0].b.c');