title: How does hashtable read correct values in case of collision?
body: <p>I have some hashtable. For instance I have two entities like</p>
  
  <pre><code>john = { 1stname: jonh, 2ndname: johnson },
  eric = { 1stname: eric, 2ndname: ericson }
  </code></pre>
  
  <p>Then I put them in hashtable:</p>
  
  <pre><code>ht["john"] = john;
  ht["eric"] = eric;
  </code></pre>
  
  <p>Let's imagine there is a collision and hashtable use chaining to fix it. As a result there should be a linked list with these two entities like this<a href="https://i.stack.imgur.com/JBGDd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JBGDd.png" alt="enter image description here"></a>
  How does hashtable understand what entity should be returned for key? Hash values are the same and it knows nothing about entities structure. For instance if I write this<code>var val = ht["john"];</code> how does hashtable (having only key value and its hash) find out that value should be <strong>john</strong> record and not <strong>eric</strong>.</p>