ramda 中有没有办法删除 ramda 中的多个对象。
这是我的数组
const availableFeatures = [
{
id: 1,
name: "TEST 1",
},
{
id: 2,
name: "TEST 2",
},
{
id: 3,
name: "TEST 3"
}
]
我想删除包含 id 1 和 2 的对象。
最佳答案
我喜欢使用 where
来构建谓词:
const x = reject(where({id: flip(includes)([1, 2])}))
console.log(x(availableFeatures));
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js"></script>
<script>const {reject, where, flip, includes} = R;</script>
<script>
const availableFeatures =
[ { id: 1
, name: "TEST 1"
},
{ id: 2
, name: "TEST 2",
},
{ id: 3
, name: "TEST 3"
}
];
</script>
关于javascript - 使用 Ramda 删除数组中的多个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59871052/