Printing object's keys and values

后端 未结 7 1019
暗喜
暗喜 2021-02-01 06:04

I want to print a key: value pair from javascript object. I can have different keys in my array so cannot hardcode it to object[0].key1

var filters = [{\"user\"         


        
相关标签:
7条回答
  • 2021-02-01 06:56

    This is looking for a term property on filters[0]:

    console.log(filters[0].term);
    

    What you actually want to do is use the value of term (in your example that will be "user") as the property identifier:

    console.log(filters[0][term]);
    
    0 讨论(0)
提交回复
热议问题