Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
phpnode
· 8y ago · 0 comments
They only need a unique id for the object, they can't hash based on the object contents because those can change and because two objects with exactly the same properties are not equal in JS:
assert({} === {}); // throws
Comments
[–]
infogulch
8y ago
But couldn't the hash be based on the object pointer or something?
[–]
tzahola
8y ago
No, because the GC is free to move objects around to compact the heap.
[–]
phpnode
OP
8y ago
No, for reasons others have said, but they can use the pointer to deal with collisions
[–]
sushibowl
8y ago
Doesn't work because the GC moves objects around in memory