Get object keys for filtered values

前端 未结 14 1384
傲寒
傲寒 2021-02-05 03:31

The case is simple - I\'ve got a following object:

Object {1: false, 2: true, 3: false, 4: false, 5: false, 6: false, 7: false, 8: true, 12: false, 13: false, 14         


        
14条回答
  •  野的像风
    2021-02-05 03:56

    You can use _.pick. Like this:

    var data = {1: false, 2: true, 3: false, 4: false, 5: false, 6: false, 7: false, 8: true, 12: false, 13: false, 14: false, 15: false, 16: false, 17: false, 18: false, 19: false}
    
    var keys = _.keys(_.pick(data, function(value) {
      return value;
    }));
    

提交回复
热议问题