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
Post a Comment