Based on my understanding of the docs (here and here) one would need a reference to the memory address for it to work:
const foo = {};
const map = new Map();
map.set(foo,'123'); // Can only be done if memory address of `foo` is known. Any other shimming would require stringification of foo
This is because JavaScript object {}
keys can only be strings (at least in ES5).
Yet I see Map
shim being available : https://github.com/zloirock/core-js#map. I tried reading the source but its too neatly abstracted (internally uses strong collection which then imports 10 more files)
Question
Answer any of the following please
- Is there a simple trick to it and can it truly even be done (without stringification)?
- Perhaps it mutates
foo
to store some string on it and then uses that as the key? - Something else and maybe I am reading the docs wrong?