Javascript: Retrieve Object Property Names
<p>I'm trying to write a function that needs to know the property names of an object being passed in, like so:</p>

<pre><code>var data = { "key1":"value1", "key2":"value2", etc}
               ^ i want the string value "key1"
</code></pre>

<p>How do I retrieve the string "key1" from <code>data</code>? I know I can set a property dynamically like <code>data[prop]=value</code> but i want to know what <code>prop</code> is from an object passed in.</p>

<p>If that doesn't make sense I suppose I could try to explain more. Thanks!</p>

<p>I eventually want to do something like:</p>

<pre><code>for (var i = 0; i&lt;data.length; i++)
{
    var name = data[i].getPropertyName() &lt;--- not a real function
    // do stuff
}
</code></pre>
