How to remove an item dynamically from an object?

0

I'm using a reducer state, which contains an object in this format:

x = {10: {nome: 'lucas'}, 20:{nome: 'beraldo'}} <br/>

And, I get an id via action.

I would like to do something like array.filter , or delete only dynamically on this object, to remove an item, for example:

delete x.actionID

But he can not understand action.ID , since he's coming from the action.

If it were an array, it would x = x.filter(nome != action.id) , but as it is object, I do not know how I can treat it.

    
asked by anonymous 27.07.2018 / 00:46

1 answer

0

You can delete by key:

delete x[actionID]
    
27.07.2018 / 20:47