javascript - Getting data from an object with a generated key -


lets assume have object this.

var foo = {   "dfsghasdgsad":{     "name":"bob",     "age":"27"   } }; 

foo have 1 object key generated. how retrieve "bob" , "27" in situation won't know generated key name be?

use object.keys:

var key = object.keys(foo)[0]; var name = foo[key].name; 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -