Get element of JS object with an index

后端 未结 7 1181
南方客
南方客 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:12

    I know it's a late answer, but I think this is what OP asked for.

    myobj[Object.keys(myobj)[0]];
    

提交回复
热议问题