Rather than using hashcodes you can use a WeakMap
. They essentially do the same thing: give you a uniqueness detector. But without the cost of the hashing algorithm, it's collision free and doesn't use much memory.
If you search you can find custom implementations of WeakMaps incase you're using a browser that doesn't support WeakMaps yet.