Get element of JS object with an index
I know it's a late answer, but I think this is what OP asked for.
myobj[Object.keys(myobj)[0]];
JS objects have no defined order, they are (by definition) an unsorted set of key-value pairs.
If by "first" you mean "first in lexicographical order", you can however use:
var sortedKeys = Object.keys(myobj).sort();
and then use:
var first = myobj[sortedKeys[0]];
myobj = {"A":["Abe"], "B":["Bob"]}
Object.keys(myobj)[0]; //return the key name at index 0
Object.values(myobj)[0] //return the key values at index 0
var myobj = {"A":["Abe"], "B":["Bob"]};
var keysArray = Object.keys(myobj);
var valuesArray = Object.keys(myobj).map(function(k) {
return String(myobj[k]);
});
var mydata = valuesArray[keysArray.indexOf("A")]; // Abe
myobj.A
------- or ----------
myobj['A']
will get you 'B'