title: Why does a number as key worked for a string key in an Object and vice-versa (Javascript)
body: <p>Curious about the following two cases:</p>
  
  <p><strong>First:</strong></p>
  
  <pre><code>const key = 2;
  const obj = { "2": "stackoverflow" };
  obj[key]; //results in "stackoverflow" but the key is 2 and not "2"
  </code></pre>
  
  <p><strong>Second:</strong></p>
  
  <pre><code>//Vice versa case
  const otherKey = "21";
  const otherObj = { 21: "youtube" };
  otherObj[otherKey]; //results in "youtube" but the key is "21" and not 21
  </code></pre>
  
  <p><strong>My conclusion:</strong></p>
  
  <p>That since keys should be string and while finding <code>key</code> (when key is seemingly a number) existence in Javascript objects it does so by <strong>type-conversion</strong> comparison and not by <strong>strict</strong> or a <strong>string conversion</strong>.</p>
  
  <p>Is there more to this why these cases work and am more interested in the how bit of that?</p>