I have an object with a single property, which name I do not know.
Using pure javascript, is the following really the shortest way to get the value of this property?
obj[Object.keys(obj)[0]]
Seems like an awful lot. Is there any better alternative? Again not using any JS libraries.
In your described scenario (having an object with one key, which you don’t know), yes, that is the shortest way of accessing it.
I don’t feel its a lot, given the circumstances by the way. Be aware tho that this will only work on ES5 enabled browsers. Without ES5, it will become a lot more: