How to use lodash to find and return an object from Array?

前端 未结 10 1101
终归单人心
终归单人心 2020-11-29 18:58

My objects:

[
    {
        description: \'object1\', id: 1
    },
    {
        description: \'object2\', id: 2
    }
    {
        description: \'object3\         


        
10条回答
  •  时光取名叫无心
    2020-11-29 19:36

    You can use the following

    import { find } from 'lodash'
    

    Then to return the entire object (not only its key or value) from the list with the following:

    let match = find(savedViews, { 'ID': 'id to match'});
    

提交回复
热议问题