title: How do I loop through or enumerate a JavaScript object?
body: <p>I have a JavaScript object like the following:</p>
  <pre><code>var p = {
      &quot;p1&quot;: &quot;value1&quot;,
      &quot;p2&quot;: &quot;value2&quot;,
      &quot;p3&quot;: &quot;value3&quot;
  };
  </code></pre>
  <p>How do I loop through all of <code>p</code>'s elements (<code>p1</code>, <code>p2</code>, <code>p3</code>...) and get their keys and values?</p>