How to filter an array/object by checking multiple values

后端 未结 2 450
执笔经年
执笔经年 2020-12-03 10:07

I\'m playing around with arrays trying to understand them more since I tend to work with them alot lately. I got this case where I want to search an array and compare it\'s

2条回答
  •  既然无缘
    2020-12-03 10:24

    You can use .filter() with boolean operators ie &&:

         var find = my_array.filter(function(result) {
           return result.param1 === "srting1" && result.param2 === 'string2';
         });
         
         return find[0];
    

提交回复
热议问题