Get element of JS object with an index

后端 未结 7 1309
南方客
南方客 2021-01-30 20:43

Ok so let\'s say that I have my object

myobj = {\"A\":[\"Abe\"], \"B\":[\"Bob\"]}

and I want to get the first element out of it. As in I want i

7条回答
  •  眼角桃花
    2021-01-30 21:22

    Object.keys(city)[0];   //return the key name at index 0
    Object.values(city)[0]  //return the key values at index 0
    

提交回复
热议问题