【发布时间】:2023-03-17 05:45:01
【问题描述】:
假设我们有类似的 json 对象,
const land={
water : "cool",
air : "heat"
}
现在如果 key = "water";
如何找到价值,而不是像这个land.water; 只需按键,也无需循环
就像
console.log(land.key); //but its not working
请帮助我.. 花了将近 4 小时但无法找到解决方案。
【问题讨论】:
-
试试
land[key] -
谢谢你,兄弟……它成功了……
标签: javascript node.js json