when I try these code:
const map=new Map([['a', 1],['b', 2],['c', 3],['d', 4],['e', 5]]);
console.log(map.keys());
map.delete('a')
console.log(map.keys());
the chrome console will show these:
MapIterator {"a", "b", "c", "d", "e"}
MapIterator {"c", "d", "e"}
"b" why not show up?
The delete() method removes the specified element from a Map object by key.
map. clear(obj); map. obj() takes an object as a parameter and removes each and every value so as to make it empty.
To delete a key from a map, we can use Go's built-in delete function. It should be noted that when we delete a key from a map, its value will also be deleted as the key-value pair is like a single entity when it comes to maps in Go.
delete() function in JavaScript. The delete() function of Map object accepts a string representing the key of an element of a map and deletes from the current Map object. This function returns true if the specified key exists in the map object else it returns false.
This is a browser compatibility issues, that happens with map.keys()
, map.values()
, map.entries()
.
The issue occurs in chrome
when deleting the first key but it works when well in safari
.
Also these properties don't even work in Mozilla
, just returns an empty Map iterator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With