This question already has answers here:
Get JavaScript object from array of objects by value of property [duplicate]
                            
                                (17个答案)
                            
                    
                3年前关闭。
        

    

假设我有这样的事情:

var SucessList = [
 {
  id: 1,
  dedicated: true
 },
 {
  id: 2,
  dedicated: false
 }
];


我想做一个if函数来检查是否专用== true。我该如何选择像这样专用?

最佳答案

let res = SucessList.filter(({dedicated}) => dedicated);

09-19 15:15