javascript's object: Get only the first key of an object : <p>I'm trying currently to get only the first key of an object for my process. It would allow me to make some comparisons with the root of different objects. </p>

<p>currently I use a loop and break at the first instance. Maybe there is more relevant way to achieve this goal? </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var objectKey
var p = {
    "p1": "value1",
    "p2": "value2",
    "p3": "value3"
};


for (var key in p) {
    if (p.hasOwnProperty(key)) {
        var objectKey=key;        
        break
    }
}

 console.log("the first key is: "  + objectKey)</code></pre>
</div>
</div>
</p>

<p>any hint would be great,
thanks </p>
