I have myMap: { [key: string]: string[] } = {}
and I want to remove a value for some certain key from myMap
.
That is delete value1
from myMap[Key1]
.
I have done my google search but I failed to find it.
I have myMap: { [key: string]: string[] } = {}
and I want to remove a value for some certain key from myMap
.
That is delete value1
from myMap[Key1]
.
I have done my google search but I failed to find it.
You can either remove both key and value:
myMap.delete(key);
Or reassign the value to undefined
:
myMap.set(key, undefined);
Do note the first solution comes up with a Google search of javascript map delete value
You can do it in two ways:
delete
(mutation)delete myMap[Key1]
_
will be created.const {[Key1]: _, ...updatedMyMap} = myMap