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:
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.