我有以下数组:
var phyList = [
{
"firstName": "Michael",
"lastName": "Abbey-Mensah",
"status": "Courtesy",
"specialty": "Pediatrics",
"address": "4564454, Brooklyn, NY 11212",
"phone": "718 || 718.385.9279"
},
{
"firstName": "Niraj",
"lastName": "Acharya",
"status": "Active",
"specialty": "Medicine",
"address": "4545 Avenue, Jamaica NY 11432",
"phone": "4545.558.2894 || 4545.558.9735"
}
];
如果我想在第一个条目中拥有多个专业怎么办? 比如说儿科和外科。
这行得通吗:
var phyList = [
{
"firstName": "Michael",
"lastName": "Abbey-Mensah",
"status": "Courtesy",
"specialty": ["Pediatrics", "Surgery"],
"address": "454545ergaston Blvd, Brooklyn, NY 11212",
"phone": "745458.485.2704 || 516.385.9279"
},
{
"firstName": "Niraj",
"lastName": "Acharya",
"status": "Active",
"specialty": "Medicine",
"address": "45459th Avenue, Jamaica NY 11432",
"phone": "718.558.2894 || 718.558.9735"
}
];
最佳答案
您可以在数组中维护特殊值:
var phyList = [
{
"firstName": "Michael",
"lastName": "Abbey-Mensah",
"status": "Courtesy",
"specialty": ["Pediatrics ","Surgery"],
"address": "437 Mothergaston Blvd, Brooklyn, NY 11212",
"phone": "718.485.2704 || 516.385.9279"
},
{
"firstName": "Niraj",
"lastName": "Acharya",
"status": "Active",
"specialty": ["Medicine"],
"address": "152-11 89th Avenue, Jamaica NY 11432",
"phone": "718.558.2894 || 718.558.9735"
}
];
关于javascript - 在数组 JQuery 中包含一个数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16299524/