我目前從JSON數組,看起來像下面號碼作爲標識符
"title": Title,
"chapters": {
"13c": {
"words": 123,
"spaces": 321
},
"15d": {
"words": 123,
"spaces": 321
},
"38h": {
"words": 123,
"spaces": 321
}
}
事情提取數據時,我儘量選擇13C(如果存在)具有以下
if(book.chapters.13c){
console.log(book.chapters.13c);
}
我得到以下錯誤:
Uncaught SyntaxError: Unexpected token ILLEGAL
變量名不應以數字開始。這就是爲什麼它拋出一個錯誤。 –
有什麼辦法可以繞過這個嗎? – user2536680
c13將是一個有效的變量名稱 –