Home >Web Front-end >JS Tutorial >Analysis of the value method when the json key is a number_javascript skills
How to get the value when the key of json is a number, such as:
var aa={'111':'aaaaa'};
alert(sss.111);
This won't work, alert won't play anything.
The key of json must be an object to retrieve something, such as:
var aa={'s111s':'aaaaa'};
var idd="s111s";
alert(sss.idd);
Answer:
For numeric key names or abnormal variable characters (such as spaces), the aa[x] method must be used.
var aa={'111':'aaaaa'};
alert(sss["111"]);