99
rated 0 times
[
106]
[
7]
/ answers: 1 / hits: 5483
/ 5 Years ago, sat, april 27, 2019, 12:00:00
I have this code here:
const myMap = new Map()
myMap.set(banana, true)
myMap.set(apple, true)
Object.keys(myMap).forEach(key => {myMap.set(key, false)})
console.log(myMap.get(banana)) // returns true should return false
console.log(myMap.get(apple)) // returns true should return false
I want to set all the values of this Map
to false
, but it doesn't work at all.
I've tried something like this:
Object.keys(myMap).forEach(key => myMap[key] = false)
but this doesn't work either.
Is there a way to fill all keys of a Map
to a specific value?
More From » javascript