Loop through JavaScript object
<p>I have a JavaScript object like the following </p>

<pre><code> var p =
    {
        "p1": "value1",
        "p2": "value2",
        "p3": "value3"
    };
</code></pre>

<p>Now I want to loop through all <code>p</code> elements (<code>p1</code>,<code>p2</code>,<code>p3</code>...) and get their key and values. How can I do that? I can modify the JavaScript object if necessary . My ultimate goal is to loop through some key value pairs. And if possible I want to avoid using <code>eval</code>.</p>
