javascript - 我可以在 Javascript 的过滤器函数中使用两个包含方法吗?
问题描述
我可以在 Javascript 的过滤器函数中使用两个包含方法吗?
我想要一个没有这些状态的新数组(“活动”、“已退款”)。我怎样才能做到这一点?我正在考虑使用两种包含方法,但它似乎不起作用。
const availableModules = [
{
key: "tshirt",
color: "#305b2d",
status: "active",
modules:
[
{ key: "tshirt",
color: "#066da0",
status: "active step 2"},
{ key: "tshirt",
color: "#772016",
status: "active step 3"}
],
},
{
key: "tshirt",
color: "#742016",
status: "canceled",
},
{
key: "hat",
color: "#201010",
status: "refunded",
},
{
key: "short",
color: "#702213",
status: "delivered",
},
{
key: "short",
color: "#702010",
status: "Pending",
},
{
key: "shirt",
color: "#702411",
status: "Closed",
},
];
const seeOther = availableModules.filter(m=> console.log(!m.status.includes('active', 'refunded')))
解决方案
你试过这样
availableModules.filter(x => ((x.status !== "active") && (x.status !== "refunded")))
推荐阅读
- anylogic - Anylogic - 使用自定义 GIS 路线绘制动画帧时出错
- vue.js - 防止 vue-router 打开相同的路径
- angular - Mat-select 输入组合对象
- sql - 如何从 SQL 中的活动日志中计算“活动用户”聚合?
- c# - 每次使用新数字重复文本 X 数量
- ios - 可点击的火种卡 SwiftUI
- ios - 创建可以从任何地方访问的公共选择器
- tensorflow - 对 Tensorflow 算法功能感到困惑
- react-native - 有没有办法在模态的深色 bg 后面突出显示/聚焦组件?
- javascript - 属性“filteredOptions”没有初始值设定项,也没有在构造函数中明确分配