Getting the values for a specific key from all objects in an array

后端 未结 7 1970
醉酒成梦
醉酒成梦 2020-12-15 04:32

I\'m running an express.js app that has a few apis feeding data to dropdown boxes. The data returned is in the form:

  [
    {
        key: \'blah\',
                


        
7条回答
  •  一整个雨季
    2020-12-15 04:55

    Using lodash,

    Since lodash 4.x the _.pluck function has been removed in support to map function.

    so you can achieve the desired task by:

    import _ from 'lodash'
    _.map(items, 'key');
    

    Ref: What happened to Lodash _.pluck?

提交回复
热议问题