L
L
Little Vasya2020-05-10 09:01:43
JavaScript
Little Vasya, 2020-05-10 09:01:43

How to remove a key in an object from LocalStorage?

There is a caretaker

{3: {}, 4: {}, 5: {}}
3: {}
4: {}
5: {}

I do so
LocalStorage.setItem(TEMPORARY_STATE, Object.assign(blocks, { ...state.tmp, [block.id]: {} }))


So, instead of retrieving an empty object, I need to delete it, the delete operator cannot be networked

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Demian Smith, 2020-05-10
@emilov

Unfortunately, removing a key from an object using destructuring looks like a terrible ugly no matter how hard you try. I advise you to create a helper function `omit(keys, object)` like omit from the lodash or ramda libraries. https://github.com/ramda/ramda/blob/master/source/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question