TIL... How to delete a property from a javascript object

2018-04-24 This post is over 2 years old

While working in a reducer, I found I needed to close/remove an entry from a dictionary. After a brief amount of digging I found that I did not have to write this functionality myself. The kind folk of Lodash have you covered. Simple _omit_ the property. Like so:

1
2
3
import omit from 'lodash/omit'

default export (object)=>omit(object,removedKey);

Lodash/Omit kindly returns a new object, omitting the given key.