访问Javascript中的嵌套对象数组 [英] Accessing nested array of objects in Javascript
本文介绍了访问Javascript中的嵌套对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象数组(allCities)和一个嵌套的对象数组("Residing City").我该如何循环访问每个城市"?键的值?
I have an array of objects (allCities) with a nested array of objects ("Residing City"). How can I loop through and access each "City" key's value?
const allCities = [
{
"Residing City": [
{
City: "Tokyo",
Country: "Japan"
},
{
City: "London",
Country: "UK"
},
{
City: "Paris",
Country: "France"
}
],
}
]
推荐答案
allCities[0]['Residing City'].forEach((t) => console.log(t.City))
您应该阅读一次.数组方法
这篇关于访问Javascript中的嵌套对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文