Have you ever figured how to get array of object from its property with single line? then try use lodash/find
npm install lodash/find # or yarn add lodash/find
import find from 'lodash/find'
const obj = [
{ name: 'vico', level: 1 },
{ name: 'ben', level: 99 }
]
const vico = find(obj, ['name', 'vico'])
console.log(vico)
// output: { name: 'vico', level: 1 }
Top comments (0)