title: Retrieve property value from array literal
body: <p>I keep getting eluded by how property values should be properly retrieved from array literals.</p>
  
  <p><strong>Object literal:</strong></p>
  
  <pre><code>var obj = {
      "p1": "v1",
      "p2": "v2",
      "p3": "v3"
  };
  
  for (var key in obj) {
      if (obj.hasOwnProperty(key)) {
          console.log(key + " -&gt; " + obj[key]);
      }
  }
  </code></pre>
  
  <p><em>Console log output:</em></p>
  
  <pre><code>p1 -&gt; v1
  p2 -&gt; v2
  p3 -&gt; v3
  </code></pre>
  
  <p><strong>Array literal:</strong></p>
  
  <pre><code>var obj = [
      { "pa":"va1", "pb":"vb1" },
      { "pa":"va2", "pb":"vb2" },
      { "pa":"va3", "pb":"vb3" },
      { "pa":"va4", "pb":"vb4" }
  ];
  
  for (var key in obj) {
      if (obj.hasOwnProperty(key)) {
          console.log(key + " -&gt; " + obj[key]);
      }
  }
  </code></pre>
  
  <p><em>Console log output (duh!):</em></p>
  
  <pre><code>0 -&gt; [object Object]
  1 -&gt; [object Object]
  2 -&gt; [object Object]
  3 -&gt; [object Object]
  </code></pre>
  
  <p><strong>What I'm trying to do:</strong> <em>check if a string matches one of the <code>pa</code> values</em>. If it does, do something.</p>
  
  <p>This would be the logic:</p>
  
  <pre><code>var myString = "a value I'm getting from somewhere else ;)"
  if (myString == any of the pa values) {
      // do something
  }
  </code></pre>
  
  <p>Any help appreciated!</p>