When working with JavaScript, is it possible for setting an item in a WeakMap to change the object used as the key?
I'm curious about this because if I were to create a WeakMap, my approach might involve using a Symbol on the key and then utilizing that to access the value. This way, there would be no memory reference maintained from the WeakMap to the value.
...and I can't seem to think of any other method of achieving this.
The example below seems to suggest that modifying the key doesn't happen in the usual user-friendly manner?
const o= Object.freeze({})
const m = new WeakMap
m.set(o, 'this is o')
console.log(m.has(o)) // true