Reputation: 321
I have a object that may have some keys
const input = {
whatsapp: "123",
telegram: "bbb",
}
And I want to remove a list of possible keys:
const removeThis = ['whatsapp', 'telegram', 'signal', 'wechat']
Using Ramda, how can I remove all possible keys in the object input
?
The key may not exist in the object.
Upvotes: 1
Views: 78
Reputation: 191986
You can use 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>
Upvotes: 4