in JavaScript get first object member name
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/983267/access-the-first-property-of-an-object">Access the first property of an object</a>  </p>
</blockquote>



<p>I just want to know if there is a better way to get the first member name in a object like:</p>

<pre><code>var x={a:1};
func(x);//will return 'a'
</code></pre>

<p>I programmed a small function but I'm not satisfied, i think that there is a better way</p>

<p>what i did is :</p>

<pre><code>var get_member = function(obj){for (i in obj){if (obj.hasOwnProperty(i)) return i;}};
</code></pre>
