📜  如何从 json api 过滤多个值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:53.637000             🧑  作者: Mango

代码示例1
const filters = {forSale: true, color: 'blue'}; 
const filteredArray = array.filter(item => {
    let result = true;
    for(let key in filters) {
        if (item[key] !== filters[key]){
            result = false;
            break;
        }
    }
    return result;
})