gpt4 book ai didi

javascript - 从jquery中的对象数组中获取值

转载 作者:行者123 更新时间:2023-11-28 19:54:08 25 4
gpt4 key购买 nike

我在 jquery 中有这样的数据,如何从 user1、user2 等的组列表中获取 groupname2 值:

{"groupslist":{"groupname":["user1","user2","user3"],"groupname2":["user1","user2","user3"],"groupname3":["user1","user2","user3"]}}

我已声明 grouplist={} 并动态推送组名值,当我打印组列表时,我在控制台中得到的值是 `

Object {user00: Array[3], super user: Array[1], supreme user: Array[0]}
super user: Array[1]
0: "sample_vh.com"
length: 1
__proto__: Array[0]
supreme user: Array[0]
user00: Array[3]
0: "veera_tls.com"
1: "v_v.com"
2: "sample_vh.com"
length: 3
__proto__: Array[0]
__proto__: Object`

最佳答案

var o = {
"groupslist":{
"groupname":["user1","user2","user3"],
"groupname2":["user1","user2","user3"],
"groupname3":["user1","user2","user3"]
}
};

console.log(o.groupslist.groupname2);

关于javascript - 从jquery中的对象数组中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22895594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com