title: How to find value using key in javascript dictionary
body: <p>I have a question about Javascript's dictionary. I have a dictionary in which key-value pairs are added dynamically like this:</p>
  
  <pre><code>var Dict = []
  var addpair = function (mykey , myvalue) [
    Dict.push({
      key:   mykey,
      value: myvalue
    });
  }
  </code></pre>
  
  <p>I will call this function and pass it different keys and values. But now I want to retrieve my value based on the key but I am unable to do so. Can anyone tell me the correct way?</p>
  
  <pre><code>var givevalue = function (my_key) {
    return Dict["'" +my_key +"'"]         // not working
    return Dict["'" +my_key +"'"].value // not working
  }
  </code></pre>
  
  <p>As my key is a variable, I can't use <code>Dict.my_key</code></p>
  
  <p>Thanks.</p>