# Get Object keys in for each loop

**URL:** <https://forum.kirupa.com/t/get-object-keys-in-for-each-loop/332658>\
**Category:** web dev\
**Created:** [September 13, 2014, 4:18am UTC](https://forum.kirupa.com/t/get-object-keys-in-for-each-loop/332658 "2014-09-13T04:18:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashdaddy](https://avatars.discourse-cdn.com/v4/letter/f/e36b37/32.png) [@flashdaddy](https://forum.kirupa.com/u/flashdaddy)\
**Post date:** [September 13, 2014, 4:18am UTC](https://forum.kirupa.com/t/get-object-keys-in-for-each-loop/332658/1 "2014-09-13T04:18:37Z")

</div>

Hey All,

I’ve run into a situation where I need to get the key (not the value) of an object. I’ve been doing a lot of searching, and everything that I’ve come across is only giving me the value back. With the following code:

```auto

var someArr = ["name", "address","phoneNumber"];
var someObj = {color:"black", year:"2014", name:"william"};
var obj = ""

console.log(Object.keys(someObj));
for (obj in Object.keys(someObj)) {
    console.log("name of object " + obj);
}

```

When console logging, i get the keys, but not in the loop. I’m not exactly sure what I’m missing but if someone can give me a hand it would be much appreciated.
