我有一个 JavaScript 对象,它是多层次的,例如:
let obj = [
{
"testKeyOne": "one",
"testKeyTwo": "two"
},
{
"testKeyThree": "three",
"testKeyFour": "four",
"testKeyFive": {
"testKeyFiveAndAHalf": "5.5"
"testKeyFiveAndThreeQuarters": "5.75"
}
},
]
我还有一个用于我需要访问的键的数组,例如,如果我正在寻找那个5.5,
let array = [1, "testKeyFive", "testKeyFiveAndAHalf"]
虽然我的阵列也可能看起来像这样,如果我正在寻找 "one"
let array = [0, "testKeyOne"]
有没有办法使用数组来访问所需的值?
这是我第一次提问,所以如果我搞砸了,或者有什么不清楚的地方或需要改变的地方,我深表歉意。
谢谢!
烙印99
HUH函数
牧羊人nacy
相关分类