1var obj = { first: 'someVal' };
2obj[Object.keys(obj)[0]]; //returns 'someVal'
3
1var obj = { "a" : 1, "b" : 2, "c" : 3};
2alert(Object.keys(obj)[0]);
3// alerts "a"
4let objLength = Object.keys(obj).length
5console.log(objLength)
6// Logs 3 as "obj" has 3 keys
7var objValue = Object.values(obj)[0]
8console.log(objValue)
9// Logs "1" as the value of the first key(a) is "1"
1var example = {
2 foo1: { /* stuff1 */},
3 foo2: { /* stuff2 */},
4 foo3: { /* stuff3 */}
5};
6
7let [first] = Object.keys(example)
8
9console.log(first)