我做了一个像这样的对象:
var courtdocument= {
'CFADocuments': {
cv: [
"CFA_Pack_Cover_Letter.docx",
"Countersigned-CFA-Terms-and-Conditions-Letter.docx",
"Test-cfa-documents - Copy - Copy.docx"
]
},
'LetterOfClaim': {
cv: [
"CFA_Pack_Cover_Letter.docx",
"Countersigned-CFA-Terms-and-Conditions-Letter.docx"
]
},
'LetterOfInstruction': {
cv: [
"CFA_Pack_Cover_Letter.docx",
"Countersigned-CFA-Terms-and-Conditions-Letter.docx"
]
},
Letters: {
cv: [
]
},
'MedicalRecords': {
cv: [
]
},
'medicalreports': {
cv: [
]
}
}
我将如何获得此设置?
CFADocuments
LetterOfClaim
LetterOfInstruction
Letters
MedicalRecords
medicalreports
答案 0 :(得分:3)
如果您正在寻找courtdocument
obejct中的不同密钥,那么在现代浏览器中,您可以使用Object.keys() - IE< 9不支持您可以使用垫片,如mdn docs
console.log(Object.keys(courtdocument))
演示:Fiddle
答案 1 :(得分:0)
您只需使用courtdocument.CFADocuments
或courtdocument["CFADocuments"]
答案 2 :(得分:0)
如果您想获取一组值,请尝试:
var result = []
for (var prop in courtdocument){
if (courtdocument.hasOwnProperty(prop){
result.push(courtdocument[prop])
}
}