how to access immediate unknown key in object

前端 未结 2 493
走了就别回头了
走了就别回头了 2020-12-20 23:34

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

2条回答
  •  感情败类
    2020-12-21 00:01

    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/

提交回复
热议问题