删除对象中的键列表,该键可能不存在

Remove list of keys in object, the key may not exist

我有一个对象可能有一些键

const input = {
  whatsapp: "123",
  telegram: "bbb",
}

我想删除 可能 个键的列表:

const removeThis = ['whatsapp', 'telegram', 'signal', 'wechat']

如何使用 Ramda 删除对象中所有可能的键 input

对象中可能不存在键。

您可以使用 R.omit:

const input = {
  whatsapp: "123",
  telegram: "bbb",
  stay: 'xxx'
}

const removeThis = ['whatsapp', 'telegram', 'signal', 'wechat']

const result = R.omit(removeThis, input)

console.log(result)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.js" integrity="sha512-3sdB9mAxNh2MIo6YkY05uY1qjkywAlDfCf5u1cSotv6k9CZUSyHVf4BJSpTYgla+YHLaHG8LUpqV7MHctlYzlw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>