Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

how to access immediate unknown key in object. in pic "367:sl" is dynamic key and i want to access cptyName value which is in "367:sl". Thanks in advance

pic

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
184 views
Welcome To Ask or Share your Answers For Others

1 Answer

If your dynamic key is the only key in quotes object, you can get the first key and then access value with:

var firstKey = Object.keys(quotes)[0];
var cptyName = quotes[firstKey].cptyName;

http://jsfiddle.net/mGZpa/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...