<story><title>Optimizing hash tables: hiding the hash code</title><url>https://v8project.blogspot.com/2018/01/hash-code.html</url></story><parent_chain><item><author>Twirrim</author><text>&amp;gt; In V8, the hash code is just a random number, independent of the object value. Therefore, we can’t recompute it, meaning we must store it.&lt;p&gt;That&amp;#x27;s the most interesting point in the entire article, and there&amp;#x27;s no explanation associated.  Why are they using random numbers for the hash code?</text></item></parent_chain><comment><author>MaxBarraclough</author><text>You might enjoy this blog post exploring the surprisingly deep (and interesting) rabbit-hole of Java&amp;#x27;s Object#hashCode() method.&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;srvaroa.github.io&amp;#x2F;jvm&amp;#x2F;java&amp;#x2F;openjdk&amp;#x2F;biased-locking&amp;#x2F;2017&amp;#x2F;01&amp;#x2F;30&amp;#x2F;hashCode.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;srvaroa.github.io&amp;#x2F;jvm&amp;#x2F;java&amp;#x2F;openjdk&amp;#x2F;biased-locking&amp;#x2F;20...&lt;/a&gt;</text></comment>
<story><title>Optimizing hash tables: hiding the hash code</title><url>https://v8project.blogspot.com/2018/01/hash-code.html</url></story><parent_chain><item><author>Twirrim</author><text>&amp;gt; In V8, the hash code is just a random number, independent of the object value. Therefore, we can’t recompute it, meaning we must store it.&lt;p&gt;That&amp;#x27;s the most interesting point in the entire article, and there&amp;#x27;s no explanation associated.  Why are they using random numbers for the hash code?</text></item></parent_chain><comment><author>phpnode</author><text>They only need a unique id for the object, they can&amp;#x27;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:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    assert({} === {}); &amp;#x2F;&amp;#x2F; throws&lt;/code&gt;&lt;/pre&gt;</text></comment>